Correct me if I'm wrong but as far as I understand from the documentation,
--env option is used ONLY for being able to get access to it within webpack.config.js if it exports a function e.g.
module.exports = function(env, options) {
console.log(env); // "production"
}
and let's say that I have my entry point index.js with the following code:
console.log(process.env.NODE_ENV); // undefined ???
I wonder if
process.env.NODE_ENV won't be assigned to any value regardless I pass --env.production or --env.development
I wonder if
webpack will enable any sort of optimizations automatically depending on a value for --env
--mode option is used to enable some bunch of optimizations right away and it will set process.env.NODE_ENV to be accessible inside my source files, e.g.
console.log(process.env.NODE_ENV); // "production" OR "development", etc ???
I wonder if
process.env.NODE_ENV will be assigned to any value accessing it from within webpack.config.js
I wonder if
Let's say that I run webpack with the following command $ webpack --mode="development"
and I have the following contents of webpack.config.js:
module.exports = {
devtool: 'source-map'
};
so, will the devtool option eventually be set to eval(if I weren't redefining devtool in my webpack.config.js or the value will be source-map, so it will be rewritten with those from my webpack.config.js file?