Konrad
Konrad

Reputation: 7238

Webpack environment variables confusion

edit: I think I answered my own question here

I see many projects using cross-env with webpack but what for?

I see webpack 4 has --mode option which sets NODE_ENV for us but you can only choose 3 values (production,development,none so this is pretty much a standard now): https://webpack.js.org/configuration/mode/

In webpack >=3 there is --env command-line option which basically allows you to set process.env.{some property}

So we have 4 ways now to manage environment variables... Can you explain why is it so confusing?

Related question: What is the difference between webpack --env.production and --mode="production"

More people are confused: https://www.jonathancreamer.com/webpack-production-environment-is-not-the-node_env-or-babel_env-environment-variable/

If I understand correctly in v4 --mode is the right standard way to set "development"/"production" so I will stick to that.

Upvotes: 3

Views: 137

Answers (0)

Related Questions