-
-
Notifications
You must be signed in to change notification settings - Fork 51
Description
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 optimisedNODE_ENV=production-> silent, optimised
stage 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 environment
so you can have mix like
stage=development,NODE_ENV=developmentstage=qa,NODE_ENV=productionstage=staging,NODE_ENV=productionstage=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