6.0.1 • Published 4 years ago

optimize-css-assets-webpack-plugin v6.0.1

Weekly downloads
5,082,777
License
MIT
Repository
github
Last release
4 years ago

Optimize CSS Assets Webpack Plugin

A Webpack plugin to optimize \ minimize CSS assets.

:warning: For webpack v5 or above please use css-minimizer-webpack-plugin instead.

What does the plugin do?

It will search for CSS assets during the Webpack build and will optimize \ minimize the CSS (by default it uses cssnano but a custom CSS processor can be specified).

Solves extract-text-webpack-plugin CSS duplication problem:

Since extract-text-webpack-plugin only bundles (merges) text chunks, if it's used to bundle CSS, the bundle might have duplicate entries (chunks can be duplicate free but when merged, duplicate CSS can be created).

Installation:

Using npm:

$ npm install --save-dev optimize-css-assets-webpack-plugin

:warning: For webpack v3 or below please use optimize-css-assets-webpack-plugin@3.2.0. The optimize-css-assets-webpack-plugin@4.0.0 version and above supports webpack v4.

Configuration:

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. 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:

var OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/,
        loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
      }
    ]
  },
  plugins: [
    new ExtractTextPlugin('styles.css'),
    new OptimizeCssAssetsPlugin({
      assetNameRegExp: /\.optimize\.css$/g,
      cssProcessor: require('cssnano'),
      cssProcessorPluginOptions: {
        preset: ['default', { discardComments: { removeAll: true } }],
      },
      canPrint: true
    })
  ]
};

License

MIT (http://www.opensource.org/licenses/mit-license.php)

xmi-scripts@proteria/react-scripts@savaleukhin/react-scripts@scentregroup/react-scripts@talesman/react-scripts@openbaseio/package-build-statsarcade-next-css@fiuzagr/bootcbbpa-clientcc-gram-demo@knapsack-cloud/msk-design-systemreact-wind-uismart-input-demo@vdjurdjevic/generator-react-appbyteplayerkstick-react-scripts@liuhaomin/builder-webpack@asep.setiawan/react-kit@jerryhorak/docusaurus-coreplafform-scriptswatsize-test-react-scriptsreact-tpl@psimk/react-scriptscbs_newglobal-martcomatch-mvp-debugging@darapti/darapti-react-scriptsswitch_mostqroda-sdkqroda-sdk-v1metaliquid-react-scriptsrockywu-ui@poloris/sli-vue@tomas2d/react-scriptsshared-react-scaffoldingreact-antd-scripts-newwebpack-ziminggry-ns-logingry-ns-publishjbojcic-react-scripts@tenjo/webpack-config@darkhm/essence-constructor-scripts@jvhellemondt/custom-react-scripts@st4rfox/electron-scriptshandywebpacksv-component-librarysv-component-library-1sv-component-library-2@straw-hat/neutrino@thuanpq/airvert-ui@xinyifly/react-scriptsreact-static-jurosh@ipavinthan/react-scriptsmio-cli-service@katalabut/react-scriptsandculturecode-react-scriptswebeetle-react-scriptsyadong-react@agney/react-scripts-tailwindzackmoreplay-react-scriptsgooapps-react-opsthefarm-react-scripts@wywk/headquaters-marketing-eventconcord-ui-plugin-react-scriptssebrae-boilerplatesebrae-react-scriptsstart-kit-builder-flexible@cloudhuset/zd-app-react-scriptsidelic-react-scriptstest-app-6test-app-7tm-components-test@jvhellemondt/react-scriptsearthling-interactive-react-scriptshoogo-niuyapingreact-epic-image-sliderpejann-scriptsmy-custom-react-jwplayerinversify-react-scriptselectron-cra-scriptsbuilder-webpack4-vueecom-catalogjs-advancedplatinion-paris-react-componentsreact-scripts-public-urlzula-bravosmartinput-reactstar-react-scripts@amajola/react-scripts@priyanknamdeo16/react-scripts@ashversache/toasterreactor-scripts-for-laravelorbit-shared-components@packages-pragma/react-appreact-cleanupreact-components-common-libraryprinter-editorrc-ui-designerwasm-worker-react-scriptswww-mgsoftech
6.0.1

4 years ago

5.0.8

4 years ago

5.0.7

4 years ago

5.0.6

4 years ago

5.0.5

4 years ago

6.0.0

4 years ago

5.0.4

4 years ago

5.0.3

5 years ago

3.2.1

5 years ago

5.0.2

5 years ago

5.0.1

6 years ago

5.0.0

6 years ago

4.0.3

6 years ago

4.0.2

7 years ago

4.0.1

7 years ago

4.0.0

7 years ago

3.2.0

7 years ago

3.1.1

7 years ago

3.1.0

7 years ago

3.0.0

7 years ago

2.0.0

8 years ago

1.3.2

8 years ago

1.3.1

8 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago