Ability to keep NODE_ENV as it was set during build
Describe the feature
Currently nuxt build overrides NODE_ENV to production, which is not always desirable.
We have staging builds, which require the inclusion of different keys, currently it is not possible to use the intented NODE_ENV variable for this.
Suggestion is to add a flag to omit this override feature, defaulting to false: meaning without this flag, the build will override.
Additional information
- [X] Would you be willing to help implement this feature?
- [ ] Could this feature be implemented as a module?
Final checks
- [X] Read the contribution guide.
- [X] Check existing discussions and issues.
As a workaround, you could use another env variable to differentiate between staging/prod/dev/... 🤔
Thank you for the suggestion. I'll override it again in nuxt.config.js.
Best would be to not use NODE_ENV for that but something like STAGE/APP_ENV/...
I would very strongly advise against overriding NODE_ENV. It is really not meant for distinguishing between staging/prod/dev modes and will break any number of dependencies along the way.
I would also strongly recommend depending on two development and production values for NODE_ENV. There is no standard that tells not to use other values but there were strong reasons that Nuxt CLI makes sure it remains within these two values. Many packages in node_modules can be misbehaving and assuming your application should be in development conditions when something like staging is used.
But regardless i think we should give an out of the box alternative env name to access original one (currently nuxi only makes a warn + force override)
(Linking #357)