Skip to content

Commit 0a90166

Browse files
refactor: rename plugin to css-minimizer-webpack-plugin (#12)
1 parent bbed537 commit 0a90166

35 files changed

+519
-301
lines changed

README.md

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[![chat][chat]][chat-url]
1313
[![size][size]][size-url]
1414

15-
# cssnano-webpack-plugin
15+
# css-minimizer-webpack-plugin
1616

1717
This plugin uses [cssnano](https://cssnano.co) to optimize and minify your CSS.
1818

@@ -24,18 +24,18 @@ Works with Webpack 4+.
2424

2525
## Getting Started
2626

27-
To begin, you'll need to install `cssnano-webpack-plugin`:
27+
To begin, you'll need to install `css-minimizer-webpack-plugin`:
2828

2929
```console
30-
$ npm install cssnano-webpack-plugin --save-dev
30+
$ npm install css-minimizer-webpack-plugin --save-dev
3131
```
3232

3333
Then add the plugin to your `webpack` configuration. For example:
3434

3535
**webpack.config.js**
3636

3737
```js
38-
const CssnanoPlugin = require('cssnano-webpack-plugin');
38+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
3939

4040
module.exports = {
4141
module: {
@@ -48,7 +48,7 @@ module.exports = {
4848
},
4949
optimization: {
5050
minimize: true,
51-
minimizer: [new CssnanoPlugin()],
51+
minimizer: [new CssMinimizerPlugin()],
5252
},
5353
};
5454
```
@@ -69,7 +69,7 @@ module.exports = {
6969
optimization: {
7070
minimize: true,
7171
minimizer: [
72-
new CssnanoPlugin({
72+
new CssMinimizerPlugin({
7373
test: /\.foo\.css$/i,
7474
}),
7575
],
@@ -91,7 +91,7 @@ module.exports = {
9191
optimization: {
9292
minimize: true,
9393
minimizer: [
94-
new CssnanoPlugin({
94+
new CssMinimizerPlugin({
9595
include: /\/includes/,
9696
}),
9797
],
@@ -113,7 +113,7 @@ module.exports = {
113113
optimization: {
114114
minimize: true,
115115
minimizer: [
116-
new CssnanoPlugin({
116+
new CssMinimizerPlugin({
117117
exclude: /\/excludes/,
118118
}),
119119
],
@@ -129,7 +129,7 @@ Type: `Boolean|String`
129129
Default: `true`
130130

131131
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`.
133133

134134
> ℹ️ If you use your own `minify` function please read the `minify` section for cache invalidation correctly.
135135
@@ -144,7 +144,7 @@ module.exports = {
144144
optimization: {
145145
minimize: true,
146146
minimizer: [
147-
new CssnanoPlugin({
147+
new CssMinimizerPlugin({
148148
cache: true,
149149
}),
150150
],
@@ -163,7 +163,7 @@ module.exports = {
163163
optimization: {
164164
minimize: true,
165165
minimizer: [
166-
new CssnanoPlugin({
166+
new CssMinimizerPlugin({
167167
cache: 'path/to/cache',
168168
}),
169169
],
@@ -184,9 +184,9 @@ Default cache keys:
184184

185185
```js
186186
({
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
190190
path: compiler.outputPath ? `${compiler.outputPath}/${file}` : file, // asset path
191191
hash: crypto.createHash('md4').update(input).digest('hex'), // source file hash
192192
});
@@ -199,7 +199,7 @@ module.exports = {
199199
optimization: {
200200
minimize: true,
201201
minimizer: [
202-
new CssnanoPlugin({
202+
new CssMinimizerPlugin({
203203
cache: true,
204204
cacheKeys: (defaultCacheKeys, file) => {
205205
defaultCacheKeys.myCacheKey = 'myCacheKeyValue';
@@ -233,7 +233,7 @@ module.exports = {
233233
optimization: {
234234
minimize: true,
235235
minimizer: [
236-
new CssnanoPlugin({
236+
new CssMinimizerPlugin({
237237
parallel: true,
238238
}),
239239
],
@@ -252,7 +252,7 @@ module.exports = {
252252
optimization: {
253253
minimize: true,
254254
minimizer: [
255-
new CssnanoPlugin({
255+
new CssMinimizerPlugin({
256256
parallel: 4,
257257
}),
258258
],
@@ -289,7 +289,7 @@ module.exports = {
289289
optimization: {
290290
minimize: true,
291291
minimizer: [
292-
new CssnanoPlugin({
292+
new CssMinimizerPlugin({
293293
sourceMap: true,
294294
}),
295295
],
@@ -315,10 +315,10 @@ module.exports = {
315315
optimization: {
316316
minimize: true,
317317
minimizer: [
318-
new CssnanoPlugin({
318+
new CssMinimizerPlugin({
319319
minify: (data) => {
320320
const postcss = require('postcss');
321-
const { input, postcssOptions, cssnanoOptions } = data;
321+
const { input, postcssOptions, minimizerOptions } = data;
322322

323323
const plugin = postcss.plugin(
324324
'custom-plugin',
@@ -344,7 +344,7 @@ module.exports = {
344344
};
345345
```
346346

347-
### `cssnanoOptions`
347+
### `minimizerOptions`
348348

349349
Type: `Object`
350350
Default: `{ preset: 'default' }`
@@ -356,8 +356,8 @@ module.exports = {
356356
optimization: {
357357
minimize: true,
358358
minimizer: [
359-
new CssnanoPlugin({
360-
cssnanoOptions: {
359+
new CssMinimizerPlugin({
360+
minimizerOptions: {
361361
preset: [
362362
'default',
363363
{
@@ -376,7 +376,7 @@ module.exports = {
376376
Type: `Function<(warning, file, source) -> Boolean>`
377377
Default: `() => true`
378378

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)).
380380
Return `true` to keep the warning, a falsy value (`false`/`null`/`undefined`) otherwise.
381381

382382
> ⚠️ The `source` argument will contain `undefined` if you don't use source maps.
@@ -388,7 +388,7 @@ module.exports = {
388388
optimization: {
389389
minimize: true,
390390
minimizer: [
391-
new CssnanoPlugin({
391+
new CssMinimizerPlugin({
392392
warningsFilter: (warning, file, source) => {
393393
if (/Dropping unreachable code/i.test(warning)) {
394394
return true;
@@ -417,7 +417,7 @@ module.exports = {
417417
Don't forget to enable `sourceMap` options for all loaders.
418418

419419
```js
420-
const CssnanoPlugin = require('cssnano-webpack-plugin');
420+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
421421

422422
module.exports = {
423423
module: {
@@ -434,7 +434,7 @@ module.exports = {
434434
},
435435
optimization: {
436436
minimizer: [
437-
new CssnanoPlugin({
437+
new CssMinimizerPlugin({
438438
sourceMap: true,
439439
}),
440440
],
@@ -450,8 +450,8 @@ Remove all comments (including comments starting with `/*!`).
450450
module.exports = {
451451
optimization: {
452452
minimizer: [
453-
new CssnanoPlugin({
454-
cssnanoOptions: {
453+
new CssMinimizerPlugin({
454+
minimizerOptions: {
455455
preset: [
456456
'default',
457457
{
@@ -475,17 +475,17 @@ Please take a moment to read our contributing guidelines if you haven't yet done
475475

476476
[MIT](./LICENSE)
477477

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
481481
[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
488488
[chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg
489489
[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

src/Webpack4Cache.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export default class Webpack4Cache {
1313
}
1414

1515
static getCacheDirectory() {
16-
return findCacheDir({ name: 'cssnano-webpack-plugin' }) || os.tmpdir();
16+
return (
17+
findCacheDir({ name: 'css-minimizer-webpack-plugin' }) || os.tmpdir()
18+
);
1719
}
1820

1921
isEnabled() {

src/Webpack5Cache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default class Cache {
3030
const digest = hash.digest(hashDigest);
3131
const cacheKeys = digest.substr(0, hashDigestLength);
3232

33-
return `${this.compilation.compilerPath}/CssnanoWebpackPlugin/${cacheKeys}/${task.file}`;
33+
return `${this.compilation.compilerPath}/CssMinimizerWebpackPlugin/${cacheKeys}/${task.file}`;
3434
}
3535

3636
get(task) {

0 commit comments

Comments
 (0)