NODE_ENV
is an interesting case when it comes to [[12factor]] rules.
It's tempting to both use it as a variable that controls many functions, or to use it to pick a collection of environment variables to use. I'd lean towards doing neither, and think of NODE_ENV
as a standard environment variable used by both [[node]] itself, and usually [[dependencies]].
Keep environment variables [[orthogonal]], especially NODE_ENV
. Don't use it to set certain Webpack settings, or only do things in prod, etc. Rely it on as little as possible, so you can tweak config at a finer grain.
Don't use it as a master switch to load a collection of environment variables either. Coupling NODE_ENV
to loading environment variables means you can't easily separate the node environment from other variables, e.g. an integration environment with NODE_ENV=production