{"id":19431,"library":"css-minimizer-webpack-plugin","title":"CssMinimizerWebpackPlugin","description":"Webpack plugin that minifies CSS using cssnano, with optional support for csso, clean-css, esbuild, and swc. Current stable version is 8.0.0, released 2026-03-02, requiring Node.js >= 20.9.0 and Webpack ^5. Unlike optimize-css-assets-webpack-plugin, it offers better source map handling, caching, and parallel processing via worker threads. Release cadence is roughly annual with patch releases for bug fixes. Ships TypeScript types.","status":"active","version":"8.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/webpack/css-minimizer-webpack-plugin","tags":["javascript","cssnano","css","csso","clean-css","swc","esbuild","webpack","webpack-plugin","typescript"],"install":[{"cmd":"npm install css-minimizer-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add css-minimizer-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add css-minimizer-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; the plugin is a Webpack plugin and requires webpack 5.x","package":"webpack","optional":false},{"reason":"default minifier; installed as a dependency of the plugin","package":"cssnano","optional":false}],"imports":[{"note":"CommonJS default export. ESM import (import CssMinimizerPlugin) also works in Node >= 18 with package.json type:module, but TypeScript users must use esModuleInterop or default import.","wrong":"import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';","symbol":"CssMinimizerPlugin","correct":"const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');"},{"note":"TypeScript users should import the options type separately; the plugin itself is a class, not a type.","wrong":"import CssMinimizerPluginOptions from 'css-minimizer-webpack-plugin';","symbol":"typeof CssMinimizerPlugin","correct":"import type { CssMinimizerPluginOptions } from 'css-minimizer-webpack-plugin';"}],"quickstart":{"code":"const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');\nconst MiniCssExtractPlugin = require('mini-css-extract-plugin');\n\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.css$/,\n        use: [MiniCssExtractPlugin.loader, 'css-loader'],\n      },\n    ],\n  },\n  optimization: {\n    minimizer: [\n      new CssMinimizerPlugin(),\n    ],\n  },\n  plugins: [new MiniCssExtractPlugin()],\n};","lang":"javascript","description":"Basic webpack configuration integrating CssMinimizerPlugin with MiniCssExtractPlugin for CSS minification in production."},"warnings":[{"fix":"Upgrade Node.js to version >= 20.9.0.","message":"Minimum supported Node.js version is 20.9.0 starting from v8.0.0.","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"Upgrade Node.js to version >= 18.12.0.","message":"Minimum supported Node.js version is 18.12.0 starting from v6.0.0.","severity":"breaking","affected_versions":">=6.0.0 <8.0.0"},{"fix":"Review cssnano v7 migration guide: https://github.com/cssnano/cssnano/releases/tag/cssnano%406.0.0","message":"Updated cssnano to v7 in v7.0.0; cssnano v7 has breaking changes.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Review cssnano v6 migration guide: https://github.com/cssnano/cssnano/releases/tag/cssnano%406.0.0","message":"Updated cssnano to v6 in v5.0.0; cssnano v6 has breaking changes.","severity":"breaking","affected_versions":">=5.0.0 <7.0.0"},{"fix":"Set devtool to one of the supported values (e.g., 'source-map').","message":"Source maps only work with source-map, inline-source-map, hidden-source-map, or nosources-source-map devtool values.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use default import: import CssMinimizerPlugin from 'css-minimizer-webpack-plugin' or const CssMinimizerPlugin = require('css-minimizer-webpack-plugin').default","cause":"Using named import (import { CssMinimizerPlugin }) in CommonJS or incorrect import style.","error":"Error: CssMinimizerPlugin is not a constructor"},{"fix":"Run 'npm install --save-dev css-minimizer-webpack-plugin'","cause":"Package not installed or in devDependencies.","error":"Module not found: Error: Can't resolve 'css-minimizer-webpack-plugin'"},{"fix":"Ensure Webpack >= 5 is installed and compatible plugin version.","cause":"Webpack version < 5 is used, or mismatched plugin version.","error":"TypeError: Cannot read properties of undefined (reading 'tapAsync')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}