All Projects → NMFR → Optimize Css Assets Webpack Plugin

NMFR / Optimize Css Assets Webpack Plugin

Licence: mit
A Webpack plugin to optimize \ minimize CSS assets.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Optimize Css Assets Webpack Plugin

Purgecss
Remove unused CSS
Stars: ✭ 6,566 (+506.84%)
Mutual labels:  webpack-plugin
Tinypng Webpack Plugin
a tinyPNG plugin for webpack
Stars: ✭ 31 (-97.13%)
Mutual labels:  webpack-plugin
Webpack Webextension Plugin
Webpack plugin that compiles WebExtension manifest.json files and adds smart auto reload
Stars: ✭ 47 (-95.66%)
Mutual labels:  webpack-plugin
Karma Webpack
Karma webpack Middleware
Stars: ✭ 818 (-24.4%)
Mutual labels:  webpack-plugin
Webpack Common Shake
CommonJS Tree Shaker plugin for WebPack
Stars: ✭ 875 (-19.13%)
Mutual labels:  webpack-plugin
Webpack Alioss Plugin
阿里 oss-webpack 自动上传插件
Stars: ✭ 35 (-96.77%)
Mutual labels:  webpack-plugin
Webpack Deep Scope Analysis Plugin
A webpack plugin for deep scope analysis
Stars: ✭ 589 (-45.56%)
Mutual labels:  webpack-plugin
Node Env Webpack Plugin
Simplified `NODE_ENV` handling with webpack
Stars: ✭ 51 (-95.29%)
Mutual labels:  webpack-plugin
Event Hooks Webpack Plugin
Event hooks plugin for webpack
Stars: ✭ 30 (-97.23%)
Mutual labels:  webpack-plugin
Dotenv Webpack
A secure webpack plugin that supports dotenv and other environment variables and only exposes what you choose and use.
Stars: ✭ 1,022 (-5.55%)
Mutual labels:  webpack-plugin
Error Overlay Webpack Plugin
Catch errors with style 💥✨
Stars: ✭ 821 (-24.12%)
Mutual labels:  webpack-plugin
Cloudflare Workers Webpack Plugin
Launch Cloudflare Workers to the Edge from the comfort of your build step 🚀
Stars: ✭ 18 (-98.34%)
Mutual labels:  webpack-plugin
Webpack Aliyun Oss
一个webpack(version >= 4)插件,上传资源到阿里云oss。可以作为webpack插件使用,也可独立使用
Stars: ✭ 36 (-96.67%)
Mutual labels:  webpack-plugin
Purifycss Webpack
UNMAINTAINED, use https://github.com/FullHuman/purgecss-webpack-plugin
Stars: ✭ 789 (-27.08%)
Mutual labels:  webpack-plugin
Html Inline Css Webpack Plugin
☄️ A webpack plugin for convert external stylesheet to the embedded stylesheet
Stars: ✭ 48 (-95.56%)
Mutual labels:  webpack-plugin
Duplicate Package Checker Webpack Plugin
🕵️ Webpack plugin that warns you when a build contains multiple versions of the same package
Stars: ✭ 635 (-41.31%)
Mutual labels:  webpack-plugin
Mpx Webpack Plugin
原生小程序开发定制 webpack 插件套装
Stars: ✭ 34 (-96.86%)
Mutual labels:  webpack-plugin
Nvue
master分支:webpack4实现一个vue的打包的项目,incremental: 实现增量模块打包
Stars: ✭ 55 (-94.92%)
Mutual labels:  webpack-plugin
Treat
🍬 Themeable, statically extracted CSS‑in‑JS with near‑zero runtime.
Stars: ✭ 1,058 (-2.22%)
Mutual labels:  webpack-plugin
Persistgraphql Webpack Plugin
PersistGraphQL Webpack Plugin
Stars: ✭ 39 (-96.4%)
Mutual labels:  webpack-plugin

Optimize CSS Assets Webpack Plugin

A Webpack plugin to optimize \ minimize CSS assets.

⚠️ 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

⚠️ For webpack v3 or below please use [email protected]. The [email protected] 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)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].