12
12
[ ![ chat] [ chat ]] [ chat-url ]
13
13
[ ![ size] [ size ]] [ size-url ]
14
14
15
- # cssnano -webpack-plugin
15
+ # css-minimizer -webpack-plugin
16
16
17
17
This plugin uses [ cssnano] ( https://cssnano.co ) to optimize and minify your CSS.
18
18
@@ -24,18 +24,18 @@ Works with Webpack 4+.
24
24
25
25
## Getting Started
26
26
27
- To begin, you'll need to install ` cssnano -webpack-plugin` :
27
+ To begin, you'll need to install ` css-minimizer -webpack-plugin` :
28
28
29
29
``` console
30
- $ npm install cssnano -webpack-plugin --save-dev
30
+ $ npm install css-minimizer -webpack-plugin --save-dev
31
31
```
32
32
33
33
Then add the plugin to your ` webpack ` configuration. For example:
34
34
35
35
** webpack.config.js**
36
36
37
37
``` js
38
- const CssnanoPlugin = require (' cssnano -webpack-plugin' );
38
+ const CssMinimizerPlugin = require (' css-minimizer -webpack-plugin' );
39
39
40
40
module .exports = {
41
41
module: {
@@ -48,7 +48,7 @@ module.exports = {
48
48
},
49
49
optimization: {
50
50
minimize: true ,
51
- minimizer: [new CssnanoPlugin ()],
51
+ minimizer: [new CssMinimizerPlugin ()],
52
52
},
53
53
};
54
54
```
@@ -69,7 +69,7 @@ module.exports = {
69
69
optimization: {
70
70
minimize: true ,
71
71
minimizer: [
72
- new CssnanoPlugin ({
72
+ new CssMinimizerPlugin ({
73
73
test: / \. foo\. css$ / i ,
74
74
}),
75
75
],
@@ -91,7 +91,7 @@ module.exports = {
91
91
optimization: {
92
92
minimize: true ,
93
93
minimizer: [
94
- new CssnanoPlugin ({
94
+ new CssMinimizerPlugin ({
95
95
include: / \/ includes/ ,
96
96
}),
97
97
],
@@ -113,7 +113,7 @@ module.exports = {
113
113
optimization: {
114
114
minimize: true ,
115
115
minimizer: [
116
- new CssnanoPlugin ({
116
+ new CssMinimizerPlugin ({
117
117
exclude: / \/ excludes/ ,
118
118
}),
119
119
],
@@ -129,7 +129,7 @@ Type: `Boolean|String`
129
129
Default: ` true `
130
130
131
131
Enable file caching.
132
- Default path to cache directory: ` node_modules/.cache/cssnano -webpack-plugin ` .
132
+ Default path to cache directory: ` node_modules/.cache/css-minimizer -webpack-plugin ` .
133
133
134
134
> ℹ️ If you use your own ` minify ` function please read the ` minify ` section for cache invalidation correctly.
135
135
@@ -144,7 +144,7 @@ module.exports = {
144
144
optimization: {
145
145
minimize: true ,
146
146
minimizer: [
147
- new CssnanoPlugin ({
147
+ new CssMinimizerPlugin ({
148
148
cache: true ,
149
149
}),
150
150
],
@@ -163,7 +163,7 @@ module.exports = {
163
163
optimization: {
164
164
minimize: true ,
165
165
minimizer: [
166
- new CssnanoPlugin ({
166
+ new CssMinimizerPlugin ({
167
167
cache: ' path/to/cache' ,
168
168
}),
169
169
],
@@ -184,9 +184,9 @@ Default cache keys:
184
184
185
185
``` js
186
186
({
187
- cssnano : require (' cssnano/package.json' ).version , // cssnano version
188
- ' cssnano -webpack-plugin' : require (' ../package.json' ).version , // plugin version
189
- ' cssnano -webpack-plugin-options' : this .options , // plugin options
187
+ cssMinimizer : require (' cssnano/package.json' ).version , // cssnano version
188
+ ' css-minimizer -webpack-plugin' : require (' ../package.json' ).version , // plugin version
189
+ ' css-minimizer -webpack-plugin-options' : this .options , // plugin options
190
190
path: compiler .outputPath ? ` ${ compiler .outputPath } /${ file} ` : file, // asset path
191
191
hash: crypto .createHash (' md4' ).update (input).digest (' hex' ), // source file hash
192
192
});
@@ -199,7 +199,7 @@ module.exports = {
199
199
optimization: {
200
200
minimize: true ,
201
201
minimizer: [
202
- new CssnanoPlugin ({
202
+ new CssMinimizerPlugin ({
203
203
cache: true ,
204
204
cacheKeys : (defaultCacheKeys , file ) => {
205
205
defaultCacheKeys .myCacheKey = ' myCacheKeyValue' ;
@@ -233,7 +233,7 @@ module.exports = {
233
233
optimization: {
234
234
minimize: true ,
235
235
minimizer: [
236
- new CssnanoPlugin ({
236
+ new CssMinimizerPlugin ({
237
237
parallel: true ,
238
238
}),
239
239
],
@@ -252,7 +252,7 @@ module.exports = {
252
252
optimization: {
253
253
minimize: true ,
254
254
minimizer: [
255
- new CssnanoPlugin ({
255
+ new CssMinimizerPlugin ({
256
256
parallel: 4 ,
257
257
}),
258
258
],
@@ -289,7 +289,7 @@ module.exports = {
289
289
optimization: {
290
290
minimize: true ,
291
291
minimizer: [
292
- new CssnanoPlugin ({
292
+ new CssMinimizerPlugin ({
293
293
sourceMap: true ,
294
294
}),
295
295
],
@@ -315,10 +315,10 @@ module.exports = {
315
315
optimization: {
316
316
minimize: true ,
317
317
minimizer: [
318
- new CssnanoPlugin ({
318
+ new CssMinimizerPlugin ({
319
319
minify : (data ) => {
320
320
const postcss = require (' postcss' );
321
- const { input , postcssOptions , cssnanoOptions } = data;
321
+ const { input , postcssOptions , minimizerOptions } = data;
322
322
323
323
const plugin = postcss .plugin (
324
324
' custom-plugin' ,
@@ -344,7 +344,7 @@ module.exports = {
344
344
};
345
345
```
346
346
347
- ### ` cssnanoOptions `
347
+ ### ` minimizerOptions `
348
348
349
349
Type: ` Object `
350
350
Default: ` { preset: 'default' } `
@@ -356,8 +356,8 @@ module.exports = {
356
356
optimization: {
357
357
minimize: true ,
358
358
minimizer: [
359
- new CssnanoPlugin ({
360
- cssnanoOptions : {
359
+ new CssMinimizerPlugin ({
360
+ minimizerOptions : {
361
361
preset: [
362
362
' default' ,
363
363
{
@@ -376,7 +376,7 @@ module.exports = {
376
376
Type: ` Function<(warning, file, source) -> Boolean> `
377
377
Default: ` () => true `
378
378
379
- Allow to filter [ cssnano] ( https://github.com/cssnano/cssnano ) warnings .
379
+ Allow to filter css-minimizer warnings (By default [ cssnano] ( https://github.com/cssnano/cssnano ) ) .
380
380
Return ` true ` to keep the warning, a falsy value (` false ` /` null ` /` undefined ` ) otherwise.
381
381
382
382
> ⚠️ The ` source ` argument will contain ` undefined ` if you don't use source maps.
@@ -388,7 +388,7 @@ module.exports = {
388
388
optimization: {
389
389
minimize: true ,
390
390
minimizer: [
391
- new CssnanoPlugin ({
391
+ new CssMinimizerPlugin ({
392
392
warningsFilter : (warning , file , source ) => {
393
393
if (/ Dropping unreachable code/ i .test (warning)) {
394
394
return true ;
@@ -417,7 +417,7 @@ module.exports = {
417
417
Don't forget to enable ` sourceMap ` options for all loaders.
418
418
419
419
``` js
420
- const CssnanoPlugin = require (' cssnano -webpack-plugin' );
420
+ const CssMinimizerPlugin = require (' css-minimizer -webpack-plugin' );
421
421
422
422
module .exports = {
423
423
module: {
@@ -434,7 +434,7 @@ module.exports = {
434
434
},
435
435
optimization: {
436
436
minimizer: [
437
- new CssnanoPlugin ({
437
+ new CssMinimizerPlugin ({
438
438
sourceMap: true ,
439
439
}),
440
440
],
@@ -450,8 +450,8 @@ Remove all comments (including comments starting with `/*!`).
450
450
module .exports = {
451
451
optimization: {
452
452
minimizer: [
453
- new CssnanoPlugin ({
454
- cssnanoOptions : {
453
+ new CssMinimizerPlugin ({
454
+ minimizerOptions : {
455
455
preset: [
456
456
' default' ,
457
457
{
@@ -475,17 +475,17 @@ Please take a moment to read our contributing guidelines if you haven't yet done
475
475
476
476
[ MIT] ( ./LICENSE )
477
477
478
- [ npm ] : https://img.shields.io/npm/v/cssnano -webpack-plugin.svg
479
- [ npm-url ] : https://npmjs.com/package/cssnano -webpack-plugin
480
- [ node ] : https://img.shields.io/node/v/cssnano -webpack-plugin.svg
478
+ [ npm ] : https://img.shields.io/npm/v/css-minimizer -webpack-plugin.svg
479
+ [ npm-url ] : https://npmjs.com/package/css-minimizer -webpack-plugin
480
+ [ node ] : https://img.shields.io/node/v/css-minimizer -webpack-plugin.svg
481
481
[ node-url ] : https://nodejs.org
482
- [ deps ] : https://david-dm.org/webpack-contrib/cssnano -webpack-plugin.svg
483
- [ deps-url ] : https://david-dm.org/webpack-contrib/cssnano -webpack-plugin
484
- [ tests ] : https://github.com/webpack-contrib/cssnano- webpack-plugin/workflows/cssnano -webpack-plugin/badge.svg
485
- [ tests-url ] : https://github.com/webpack-contrib/cssnano -webpack-plugin/actions
486
- [ cover ] : https://codecov.io/gh/webpack-contrib/cssnano -webpack-plugin/branch/master/graph/badge.svg
487
- [ cover-url ] : https://codecov.io/gh/webpack-contrib/cssnano -webpack-plugin
482
+ [ deps ] : https://david-dm.org/webpack-contrib/css-minimizer -webpack-plugin.svg
483
+ [ deps-url ] : https://david-dm.org/webpack-contrib/css-minimizer -webpack-plugin
484
+ [ tests ] : https://github.com/webpack-contrib/css-minimizer- webpack-plugin/workflows/css-minimizer -webpack-plugin/badge.svg
485
+ [ tests-url ] : https://github.com/webpack-contrib/css-minimizer -webpack-plugin/actions
486
+ [ cover ] : https://codecov.io/gh/webpack-contrib/css-minimizer -webpack-plugin/branch/master/graph/badge.svg
487
+ [ cover-url ] : https://codecov.io/gh/webpack-contrib/css-minimizer -webpack-plugin
488
488
[ chat ] : https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg
489
489
[ chat-url ] : https://gitter.im/webpack/webpack
490
- [ size ] : https://packagephobia.now.sh/badge?p=cssnano -webpack-plugin
491
- [ size-url ] : https://packagephobia.now.sh/result?p=cssnano -webpack-plugin
490
+ [ size ] : https://packagephobia.now.sh/badge?p=css-minimizer -webpack-plugin
491
+ [ size-url ] : https://packagephobia.now.sh/result?p=css-minimizer -webpack-plugin
0 commit comments