Skip to content

Commit 3c49d70

Browse files
docs: improve
1 parent dd00e2e commit 3c49d70

File tree

2 files changed

+22
-26
lines changed

2 files changed

+22
-26
lines changed

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,6 @@ module.exports = {
481481

482482
### Using custom minifier [clean-css](https://github.com/jakubpawlowicz/clean-css)
483483

484-
By default plugin uses [cssnano](https://github.com/cssnano/cssnano) package.
485-
It is possible to use another minify function.
486-
487-
> ⚠️ **Always use `require` inside `minify` function when `parallel` option enabled**.
488-
489484
**webpack.config.js**
490485

491486
```js
@@ -495,24 +490,29 @@ module.exports = {
495490
minimize: true,
496491
minimizer: [
497492
new CssMinimizerPlugin({
498-
minify: async (data, inputMap) => {
499-
// eslint-disable-next-line global-require
500-
const CleanCSS = require('clean-css');
493+
minify: CssMinimizerPlugin.cleanCssMinify,
494+
// Uncomment this line for options
495+
// minimizerOptions: { compatibility: 'ie11,-properties.merging' },
496+
}),
497+
],
498+
},
499+
};
500+
```
501501

502-
const [[filename, input]] = Object.entries(data);
503-
const minifiedCss = await new CleanCSS({ sourceMap: true }).minify({
504-
[filename]: {
505-
styles: input,
506-
sourceMap: inputMap,
507-
},
508-
});
502+
### Using custom minifier [csso](https://github.com/css/csso)
509503

510-
return {
511-
code: minifiedCss.styles,
512-
map: minifiedCss.sourceMap.toJSON(),
513-
warnings: minifiedCss.warnings,
514-
};
515-
},
504+
**webpack.config.js**
505+
506+
```js
507+
module.exports = {
508+
devtool: 'source-map',
509+
optimization: {
510+
minimize: true,
511+
minimizer: [
512+
new CssMinimizerPlugin({
513+
minify: CssMinimizerPlugin.cssoMinify,
514+
// Uncomment this line for options
515+
// minimizerOptions: { restructure: false },
516516
}),
517517
],
518518
},

src/utils.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,7 @@ async function cleanCssMinify(data, inputSourceMap, minimizerOptions) {
126126
const result = await new CleanCSS({
127127
sourceMap: inputSourceMap,
128128
...minimizerOptions,
129-
}).minify({
130-
[name]: {
131-
styles: input,
132-
},
133-
});
129+
}).minify({ [name]: { styles: input } });
134130

135131
return {
136132
code: result.styles,

0 commit comments

Comments
 (0)