R
R
RomanSS2019-02-09 11:53:17
JavaScript
RomanSS, 2019-02-09 11:53:17

Webpack 4 and Production Mode?

Hello, I set up Webpack 4 to build the project (4.29.0). In general, I figured everything out, but I can’t understand one moment with the build mode.
In webpack, there is a choice of how to include it, for the build I choose "webpack --mode production", the js file is compressed out of the box and everything seems to be fine.
1) But is everything really good? or is it better to use your settings for js compressions?
The issue with the process.env.NODE_ENV variable is also tormenting, in the webpack config it is equal to undefined.
Googling found a solution on how to configure the config for the desired mode

module.exports = (env, argv) => {
    const devMode = argv.mode !== 'production'
    // ....
}

2) What happens to js plugins, where there are checks for the process.env.NODE_ENV condition, it turns out they are incorrectly processed by undefined==="production" or does webpack somehow solve this by autocorrecting such constructions?
if(process.env.NODE_ENV === "production") {}
if(process.env.NODE_ENV === "development") {}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question