Environment Variables ​
The launchpad-cli package supports loading environment variables from .env files using the --env and --env-cascade flags. This allows you to manage different configurations for various environments (development, staging, production, etc.).
Usage ​
To load environment variables from a .env file:
bash
npx launchpad --env .envYou can also load multiple .env files in sequence:
bash
npx launchpad --env .env.local --env .envWhen loading multiple files, variables from later files will override those from earlier files if they share the same name.
Environment Cascading ​
The --env-cascade flag provides an automated way to load multiple environment files in a specific order. For example:
bash
npx launchpad --env-cascade productionThis will load files in the following order:
.env.env.local.env.production.env.production.local
Best Practices ​
Environment-Specific Files: Create separate
.envfiles for different environments:.env.developmentfor development settings.env.stagingfor staging settings.env.productionfor production settings
Security:
- Keep sensitive data (API keys, passwords) in local
.envfiles that aren't committed - Use
.env.localfor machine-specific overrides
- Keep sensitive data (API keys, passwords) in local
Documentation:
- Create a
.env.examplefile - List all required variables with example values
- Include this file in version control
- Create a
Example .env.example:
sh
# API Configuration
API_KEY=your_api_key_here
API_URL=https://api.example.com
# Database Configuration
DATABASE_URL=postgresql://user:password@localhost:5432/dbname