A webpack loader that minifies CSS using CleanCSS. Current stable version is 4.2.1 (released February 2023), with maintenance-level updates. It supports webpack 2+ and works with schema-utils v3/v4, loader-utils v1-v3. Key differentiators: minimal configuration, supports CleanCSS level 2 optimizations, source maps, and inline import options. Competing loaders like css-minimizer-webpack-plugin are more modern but this loader is simpler for basic minification. Ships TypeScript types.
npm install clean-css-loaderVerified import paths — ran on the pinned version, not inferred.
Shows webpack config with clean-css-loader, including conditional disable for dev and CleanCSS level 2 optimization.
Use an options object in webpack config instead of inline query strings.
Upgrade to Node.js >=14.
Use options object or upgrade loader-utils to v3 and pass primitive values correctly.
Remove clean-css-loader if using css-minimizer-webpack-plugin, or configure plugin to use clean-css instead.
Do not import 'clean-css-loader' in application JS; only reference it as a string or object in webpack config.
Run 'npm install --save-dev clean-css-loader' and ensure node_modules is accessible.
Upgrade webpack to >=5 and loader-utils to >=3, or downgrade clean-css-loader to 4.1.x.