@cvo/plugin-config
v0.0.0
Published
Configuration plugin for CVO Framework
Downloads
48
Readme
@cvo/plugin-config
A lightweight environment variable and configuration management plugin for CVO Framework, providing seamless dotenv integration.
🚀 Features
- Automatic Loading: Automatically finds and loads
.envfiles from the project root. - Environment Awareness: Intelligently prioritizes
.env.developmentwhenNODE_ENVis set todevelopment. - System Fallback: Uses system environment variables if no configuration files are found.
- Configurable: Support for custom paths and environment overrides.
🛠 Configuration
Register the plugin in your cvo.config.ts. It is recommended to register this plugin as early as possible in the plugins array to ensure variables are loaded before other plugins initialization.
import { defineConfig } from '@cvo/core';
import { configPlugin } from '@cvo/plugin-config';
export default defineConfig({
plugins: [
configPlugin({
path: './configs/.env.prod', // Optional: path to a specific env file
env: 'production' // Optional: override the environment detection
}),
// ... other plugins
]
});🧠 Usage
Once registered, the environment variables are available via process.env throughout your application.
// Anywhere in your app
const apiKey = process.env.API_KEY;
const dbUrl = process.env.DATABASE_URL;📁 Default Lookup Order
- Development:
.env.development->.env - Production/Other:
.env
