Nyxynyx
Nyxynyx

Reputation: 63599

Use uglifyjs-webpack-plugin in `plugins` or in `minimizer` section of Webpack config?

When using the uglifyjs-webpack-plugin in your Webpack config files, should the plugin be used in the plugin section (based on this article) as showed in the first webpack config below?

Or in the minimizer section, as shown in the second webpack config (based on uglifyjs-webpack-plugin docs)?

Using [email protected], [email protected], [email protected]

webpack config #1

const UglifyJsPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
    plugins: [
        new UglifyJsPlugin(),
    }),
    ...

webpack config #2

const UglifyJsPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
    optimization: {
        minimizer: [
            new UglifyJsPlugin()
        ]
    }
    ...

Upvotes: 0

Views: 792

Answers (1)

sydeng
sydeng

Reputation: 184

With the latest version of web pack(i.e > 4), it is sufficient if you include only in optimization: {minimizer: [] } section

Upvotes: 1

Related Questions