Describe the bug
This is a follow up from this comment thread. --node-env was renamed in webpack-cli v5 with this comment linked as the reasoning.
I wanted to rename node-env, because it is confising, many developers using node-env think that it will change process.env.NODE_ENV inside webpack.config.js, but it only change process.env.NODE_ENV in code, that is why I think we need another name for this.
This is not true, not in the previous version and not in the new version. See "To Reproduce" section below for a very minimal demo proving this isn't true.
What is the current behavior?
process.env.NODE_ENV is set to the value of --node-env/--define-process-env-node-env within both webpack.config.js and the rest of the application.
To Reproduce
These are the only two files needed to reproduce. Install the dependencies and run either command and see the value logged.
Gist: https://gist.github.com/CreativeTechGuy/ae6ec05ee9ec5cb71807f2ff74a99c41
Expected behavior
There's a conflict. --define-process-env-node-env is named as such to (attempt to) make it clear that it doesn't set the environment variable within webpack.config.js. That precondition doesn't seem to be true. So the previous name --node-env is much simpler and easier to understand and does do what you'd expect it to do.
Describe the bug
This is a follow up from this comment thread.
--node-envwas renamed inwebpack-cliv5 with this comment linked as the reasoning.This is not true, not in the previous version and not in the new version. See "To Reproduce" section below for a very minimal demo proving this isn't true.
What is the current behavior?
process.env.NODE_ENVis set to the value of--node-env/--define-process-env-node-envwithin bothwebpack.config.jsand the rest of the application.To Reproduce
These are the only two files needed to reproduce. Install the dependencies and run either command and see the value logged.
Gist: https://gist.github.com/CreativeTechGuy/ae6ec05ee9ec5cb71807f2ff74a99c41
Expected behavior
There's a conflict.
--define-process-env-node-envis named as such to (attempt to) make it clear that it doesn't set the environment variable withinwebpack.config.js. That precondition doesn't seem to be true. So the previous name--node-envis much simpler and easier to understand and does do what you'd expect it to do.