nuxt/cli

Ability to keep NODE_ENV as it was set during build

Opened this issue · 6 comments

smil2k commented

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

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

manniL commented

As a workaround, you could use another env variable to differentiate between staging/prod/dev/... 🤔

smil2k commented

Thank you for the suggestion. I'll override it again in nuxt.config.js.

manniL commented

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.

pi0 commented

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)