Skip to content

Commit be32f4a

Browse files
hulkishEugeneHlushko
authored andcommitted
document when optimization.minimizer is fn (#2743)
1 parent cfc324a commit be32f4a

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

src/content/configuration/optimization.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,42 @@ T> Learn how [mode](/concepts/mode/) works.
4040

4141
## `optimization.minimizer`
4242

43-
`[TerserPlugin]`
43+
`[<plugin>]` and or `[function (compiler)]`
4444

4545
Allows you to override the default minimizer by providing a different one or more customized [TerserPlugin](/plugins/terser-webpack-plugin/) instances.
4646

4747
__webpack.config.js__
4848

49-
5049
```js
5150
const TerserPlugin = require('terser-webpack-plugin');
5251

5352
module.exports = {
54-
//...
5553
optimization: {
5654
minimizer: [
57-
new TerserPlugin({ /* your config */ })
58-
]
55+
new TerserPlugin({
56+
cache: true,
57+
parallel: true,
58+
sourceMap: true, // Must be set to true if using source-maps in production
59+
terserOptions: {
60+
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
61+
}
62+
}),
63+
],
64+
}
65+
};
66+
```
67+
68+
Or, as function:
69+
70+
```js
71+
module.exports = {
72+
optimization: {
73+
minimizer: [
74+
(compiler) => {
75+
const TerserPlugin = require('terser-webpack-plugin');
76+
new TerserPlugin({ /* your config */ }).apply(compiler);
77+
}
78+
],
5979
}
6080
};
6181
```

0 commit comments

Comments
 (0)