Hi!
This is a follow-up to #30.
I use multiple dotenv files -- one per deploy target. My config/dotenv.js has logic to select a specific dotenv file provided in a DOTENV_FILE env var (see #25). If DOTENV_FILE is empty, then it picks a default one depending on environment.
The problem is that config/dotenv.js runs before the ember-cli-deploy pipeline. It selects the development dotenv file, then the ember deploy prod command makes ember-cli-deploy use the production environment. The build becomes faulty.
I have to run DOTENV_FILE=prod ember deploy prod every time, which is annoyingly redundant.
I ended up using this workaround:
function deployEnv () {
if (
process.argv[2] === 'deploy'
&& (process.argv[3] === 'prod' || process.argv[3] === 'production')
) {
return 'production'
}
}
let environment =
process.env.EMBER_ENV
|| deployEnv()
|| 'development'
Maybe ember-cli-dotenv can do a similar thing to assume the environment. Maybe Ember CLI even offers a more robust way to access the command line params.
Hi!
This is a follow-up to #30.
I use multiple dotenv files -- one per deploy target. My
config/dotenv.jshas logic to select a specific dotenv file provided in aDOTENV_FILEenv var (see #25). IfDOTENV_FILEis empty, then it picks a default one depending onenvironment.The problem is that
config/dotenv.jsruns before theember-cli-deploypipeline. It selects the development dotenv file, then theember deploy prodcommand makesember-cli-deployuse the production environment. The build becomes faulty.I have to run
DOTENV_FILE=prod ember deploy prodevery time, which is annoyingly redundant.I ended up using this workaround:
Maybe
ember-cli-dotenvcan do a similar thing to assume the environment. Maybe Ember CLI even offers a more robust way to access the command line params.