Skip to content

retyui/clean-css-loader

Repository files navigation

A clean-css loader for webpack.

clean-css-loader

npm CI npm clean-css-loader

Getting Started

To begin, you'll need to install clean-css-loader:

yarn add -D clean-css-loader

Then add the plugin to your webpack config. For example:

// webpack.config.js
const isProduction = process.env.NODE_ENV === "production";

module.exports = {
  mode: isProduction ? "production" : "development",
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          "style-loader",
          "css-loader",
          {
            loader: "clean-css-loader",
            options: {
              // Loader options
              disable: !isProduction,
              skipWarn: false,

              // CleasCSS options
              compatibility: "ie9",
              level: 2,
              inline: ["remote"],
              //...
            },
          },
        ],
      },
    ],
  },
};

CLI usage

webpack --module-bind 'css=style-loader!css-loader!clean-css-loader'

In your application

import cssMin from "style.css";

Inline

In your application

import cssMin from "style-loader!css-loader!clean-css-loader!./style.css";

Options

disable

This option enables/disables minify, useful to easily disable on development mode (default: false)

skipWarn

This option enables/disables output warnings (default: false)


CleanCSS module options