@@ -188,12 +188,19 @@ module.exports = {
188
188
### ` minify `
189
189
190
190
Type: ` Function|Array<Function> `
191
- Default: ` undefined `
191
+ Default: ` CssMinimizerPlugin.cssnano `
192
192
193
- Allows you to override default minify function.
193
+ Allows to override default minify function.
194
194
By default plugin uses [ cssnano] ( https://github.com/cssnano/cssnano ) package.
195
195
Useful for using and testing unpublished versions or forks.
196
196
197
+ Possible options:
198
+
199
+ - CssMinimizerPlugin.cssnano
200
+ - CssMinimizerPlugin.csso
201
+ - CssMinimizerPlugin.cleanCss
202
+ - async (data, inputMap, minimizerOptions) => {return {code: ` a{color: red} ` , map: ` ... ` , warnings: [ ] }}
203
+
197
204
> ⚠️ ** Always use ` require ` inside ` minify ` function when ` parallel ` option enabled** .
198
205
199
206
#### ` Function `
@@ -230,7 +237,7 @@ module.exports = {
230
237
.process (input, postcssOptions)
231
238
.then ((result ) => {
232
239
return {
233
- css : result .css ,
240
+ code : result .css ,
234
241
map: result .map ,
235
242
warnings: result .warnings (),
236
243
};
@@ -247,6 +254,37 @@ module.exports = {
247
254
If an array of functions is passed to the ` minify ` option, the ` minimizerOptions ` must also be an array.
248
255
The function index in the ` minify ` array corresponds to the options object with the same index in the ` minimizerOptions ` array.
249
256
257
+ ** webpack.config.js**
258
+
259
+ ``` js
260
+ module .exports = {
261
+ optimization: {
262
+ minimize: true ,
263
+ minimizer: [
264
+ new CssMinimizerPlugin ({
265
+ minimizerOptions: [
266
+ {}, // Options for the first function (CssMinimizerPlugin.cssnano)
267
+ {}, // Options for the second function (CssMinimizerPlugin.cssClean)
268
+ {}, // Options for the third function
269
+ ],
270
+ minify: [
271
+ CssMinimizerPlugin .cssnano ,
272
+ CssMinimizerPlugin .cssClean ,
273
+ async (data , inputMap , minimizerOptions ) => {
274
+ // To do something
275
+ return {
276
+ code: ` a{color: red}` ,
277
+ map: ` {"version": "3", ...}` ,
278
+ warnings: [],
279
+ };
280
+ },
281
+ ],
282
+ }),
283
+ ],
284
+ },
285
+ };
286
+ ```
287
+
250
288
### ` minimizerOptions `
251
289
252
290
Type: ` Object|Array<Object> `
0 commit comments