diff --git a/README.md b/README.md index 4a382d9..092e2b0 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ The plugin can receive the following options (all of them are optional): * assetNameRegExp: A regular expression that indicates the names of the assets that should be optimized \ minimized. The regular expression provided is run against the filenames of the files exported by the ExtractTextPlugin instances in your configuration, not the filenames of your source CSS files. Defaults to `/\.css$/g` * 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). * cssProcessorOptions: The options passed to the cssProcessor, defaults to `{}` +* cssProcessorPluginOptions: The plugin options passed to the cssProcessor, defaults to `{}` * canPrint: A boolean indicating if the plugin can print messages to the console, defaults to `true` ## Example: @@ -45,7 +46,9 @@ module.exports = { new OptimizeCssAssetsPlugin({ assetNameRegExp: /\.optimize\.css$/g, cssProcessor: require('cssnano'), - cssProcessorOptions: { discardComments: { removeAll: true } }, + cssProcessorPluginOptions: { + preset: ['default', { discardComments: { removeAll: true } }], + }, canPrint: true }) ] diff --git a/src/index.js b/src/index.js index 4cfb8a5..71e8abe 100644 --- a/src/index.js +++ b/src/index.js @@ -23,6 +23,9 @@ class OptimizeCssAssetsWebpackPlugin extends LastCallWebpackPlugin { this.options.cssProcessorOptions = !options || options.cssProcessorOptions === undefined ? {} : options.cssProcessorOptions; + this.options.cssProcessorPluginOptions = !options || options.cssProcessorPluginOptions === undefined ? + {} : + options.cssProcessorPluginOptions; } buildPluginDescriptor() { @@ -59,7 +62,7 @@ class OptimizeCssAssetsWebpackPlugin extends LastCallWebpackPlugin { } } return this.options - .cssProcessor.process(css.source, processOptions) + .cssProcessor.process(css.source, processOptions, this.options.cssProcessorPluginOptions) .then(r => { if (processOptions.map && r.map && r.map.toString) { assets.setAsset(assetName + '.map', r.map.toString());