Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Currently, mode only sets the value for NODE_ENV in the DefinePlugin but not changes the process.env.NODE_ENV.
For example, Babel depends on this env variable and when used with webpack --mode=production it will still run in development mode.
If the current behavior is a bug, please provide the steps to reproduce.
Running webpack --silent --mode=production && echo $NODE_ENV
This will NOT print anything.
Run NODE_ENV=production && webpack --silent --mode=production && echo $NODE_ENV
This will print production
What is the expected behavior?
Running webpack --silent --mode=production && echo $NODE_ENV should print production
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Currently,
modeonly sets the value forNODE_ENVin theDefinePluginbut not changes theprocess.env.NODE_ENV.For example, Babel depends on this env variable and when used with
webpack --mode=productionit will still run indevelopmentmode.If the current behavior is a bug, please provide the steps to reproduce.
Running
webpack --silent --mode=production && echo $NODE_ENVThis will NOT print anything.
Run
NODE_ENV=production && webpack --silent --mode=production && echo $NODE_ENVThis will print
productionWhat is the expected behavior?
Running
webpack --silent --mode=production && echo $NODE_ENVshould printproduction