Picking a specific dotenv file via CLI param
Hi!
I find splitting dotenv files by environment to be very restricting. I've seen whole blog posts arguing that it's a bad practice.
Instead, I organize my dotenv files by deploy target, e. g. development, staging, production. This unleashes my debugging capabilities, letting me make production builds against a local server and unminified builds against production server.
To achieve that, I use a very simple technique in ember-cli-build.js:
const target = process.env.APPNAME_DEPLOY_TARGET || 'localhost-4200'
const dotEnvFile = `./.env-${target}`
if (!fs.existsSync(dotEnvFile)) throw new Error(`ember-cli-build.js: dot-env file not found: ${dotEnvFile}`)
dotEnv: {
path: dotEnvFile
}
I believe this should be part of the addon. Doing ember s --dotenv .env-production is a feature that everyone would expect from the addon.
Hi @lolmaus.
I agree that this would be an awesome feature! Do you have time to write a PR for it?
@lolmaus running ember s --dotenv .env-production produces a warning from ember-cli:
The option '--dotenv' is not registered with the serve command. Run `ember serve --help` for a list of supported options.
Do you see any problem using env variable instead of command option, e.g. EMBER_DOTENV=.env-production ember s?
Approach with env variable would also allow to solve problem with #30 - seems there is POC for the solution, but problem is that we can not access environment name as the early stage of addon lifecycle. Add early stage of addon lifecycle seems is the only option to support Ember CLI >= 2.16.