iQ.
iQ.

Reputation: 3953

Webpack 4 optimize-minimize ignored with mode=development

I used to use Webpack 3 where I had 3 different builds:

  1. A full debug build where the code is unminified and is similiar to the mode=development.

  2. A test build where it is similar to mode=development but it uses minified code for smaller package size.

  3. A prod build which is basically the same as mode=production and the -p flag.

What I a having trouble is replicating my 'test' build where I had a development version of my bundle (mainly to keep react development tools) but had a bundle size that was nearly close to my production build.

Here is what I have:

NODE_ENV='development' webpack --optimize-minimize --mode=development

This no longer works as the optimize-minimize flag is being ignored so my bundle is pretty big.

Upvotes: 1

Views: 1261

Answers (1)

user4809162
user4809162

Reputation:

Use the webpack.config.js file, and ensure minimize is set to true within optimization.

optimization: {
        minimize: true,
        minimizer: [new TerserPlugin({
            terserOptions: {
              mangle: true, // Note `mangle.properties` is `false` by default.
            },
        })],
},

Upvotes: 2

Related Questions