A clean-css loader for webpack.
npm CI clean-css-loader install size npm clean-css-loader
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 = { 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"], //... }, }, ], }, ], }, };
Or using plugin inline:
// default import "style-loader!css-loader!clean-css-loader!./style.css"; // with options (query params) import "style-loader!css-loader!clean-css-loader?level=2&skipWarn=true!./style.css"; // with options (options as JSON) import "style-loader!css-loader!clean-css-loader?{\"skipWarn\": true,\"level\":2}!./style.css";
This option enables/disables minify, useful to easily disable on development mode (default: false
)
This option enables/disables output warnings (default: false
)
Enables/Disables generation of source maps. (default: compiler.devtool
)