Is your feature request related to a problem? Please describe.
NODE_ENV and stage are two different things,
NODE_ENV usually controls let's say for the sake of simplicity just "optimizations"
NODE_ENV=development -> very verbose, non optimised
NODE_ENV=production -> silent, optimised
stage represents where the application should be deployed, it can specify different database, file storage etc.
stage=development - for development purposes
stage=qa - for acceptance testing
stage=staging - preproduction testing
stage=production - production environment
so you can have mix like
stage=development, NODE_ENV=development
stage=qa, NODE_ENV=production
stage=staging, NODE_ENV=production
stage=production, NODE_ENV=production
because of getEnvironment() function, it's impossible to differentiate by stage if NODE_ENV has been specified as well. and it must be specified due to other toolings that required that env variable.
getEnvironment(options) {
return (
process.env.NODE_ENV || options.env || options.stage || 'development'
);
}
Describe the solution you'd like
Not sure what would be the best, but I'd suggest completely remove NODE_ENV from that setup, but because we don't want to break existing usage, I'd introduce some option
custom:
dotenv:
# default: false
ignoreNodeEnv: true
and to adjust getEnvironment() like this
getEnvironment(options) {
return (
!this.config.ignoreNodeEnv && process.env.NODE_ENV || options.env || options.stage || 'development'
);
}
Describe alternatives you've considered
Writing own parser donEnvParser
Is your feature request related to a problem? Please describe.
NODE_ENVandstageare two different things,NODE_ENVusually controls let's say for the sake of simplicity just "optimizations"NODE_ENV=development-> very verbose, non optimisedNODE_ENV=production-> silent, optimisedstage represents where the application should be deployed, it can specify different database, file storage etc.
stage=development- for development purposesstage=qa- for acceptance testingstage=staging- preproduction testingstage=production- production environmentso you can have mix like
stage=development,NODE_ENV=developmentstage=qa,NODE_ENV=productionstage=staging,NODE_ENV=productionstage=production,NODE_ENV=productionbecause of
getEnvironment()function, it's impossible to differentiate by stage ifNODE_ENVhas been specified as well. and it must be specified due to other toolings that required that env variable.Describe the solution you'd like
Not sure what would be the best, but I'd suggest completely remove
NODE_ENVfrom that setup, but because we don't want to break existing usage, I'd introduce some optionand to adjust
getEnvironment()like thisDescribe alternatives you've considered
Writing own parser donEnvParser