Skip to content

Commit 5a9f467

Browse files
committed
Move cssnano dependency to peerDependencies
This will not force cssnano instalation if custom dependency is being used. Also allows for more controll over the version of cssnano that will be used. WARN: This is a breaking change.
1 parent b5afe3b commit 5a9f467

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

README.md

+19-4
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,33 @@ A Webpack plugin to optimize \ minimize CSS assets.
44

55
## What does the plugin do?
66

7-
It will search for CSS assets during the Webpack build and will optimize \ minimize the CSS (by default it uses [cssnano](http://github.com/ben-eb/cssnano) but a custom css processor can be specified).
7+
It will search for CSS assets during the Webpack build and will optimize \ minimize the CSS (by default it uses [cssnano](http://github.com/ben-eb/cssnano) but a custom CSS processor can be specified).
8+
9+
Note: To use the default CSS processor, [cssnano](http://github.com/ben-eb/cssnano) must be explicitly installed (since it's a peer dependency).
810

911
### Solves [extract-text-webpack-plugin](http://github.com/webpack/extract-text-webpack-plugin) CSS duplication problem:
1012

1113
Since [extract-text-webpack-plugin](http://github.com/webpack/extract-text-webpack-plugin) only bundles (merges) text chunks, if its used to bundle CSS, the bundle might have duplicate entries (chunks can be duplicate free but when merged, duplicate CSS can be created).
1214

15+
## Installation:
16+
17+
Using npm:
18+
```shell
19+
$ npm install --save-dev optimize-css-assets-webpack-plugin
20+
```
21+
22+
If you are not going to specify a CSS processor you will also need to install [cssnano](http://github.com/ben-eb/cssnano) (since it's a peer dependency):
23+
24+
```shell
25+
$ npm install --save-dev cssnano
26+
```
27+
1328
## Configuration:
1429

1530
The plugin can receive the following options (all of them are optional):
16-
* assetNameRegExp: A regular expression that indicates the names of the assets that should be optimized \ minimized, defaults to `/\.css$/g`
17-
* cssProcessor: The css processor used to optimize \ minimize the CSS, defaults to [cssnano](http://github.com/ben-eb/cssnano). This should be a function that follows cssnano.process interface (receives a css and options parameters and returns a Promise).
18-
* cssProcessorOptions: The options passed to the cssProcessor, defaults to `{}`
31+
* assetNameRegExp: A regular expression that indicates the names of the assets that should be optimized \ minimized, defaults to `/\.css$/g`
32+
* cssProcessor: The CSS processor used to optimize \ minimize the CSS, defaults to [cssnano](http://github.com/ben-eb/cssnano). This should be a function that follows cssnano.process interface (receives a CSS and options parameters and returns a Promise).
33+
* cssProcessorOptions: The options passed to the cssProcessor, defaults to `{}`
1934
* canPrint: A boolean indicating if the plugin can print messages to the console, defaults to `true`
2035

2136
## Example:

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
"author": "Nuno Rodrigues",
55
"description": "A Webpack plugin to optimize \\ minimize CSS assets.",
66
"dependencies": {
7-
"cssnano": "^3.4.0",
87
"underscore": "^1.8.3",
98
"webpack-sources": "^0.1.0"
109
},
10+
"peerDependencies": {
11+
"cssnano": ">=3.4.0"
12+
},
1113
"main": "index.js",
1214
"homepage": "http://github.com/NMFR/optimize-css-assets-webpack-plugin",
1315
"repository": {

0 commit comments

Comments
 (0)