{"id":31916909,"url":"https://github.com/webpack/css-minimizer-webpack-plugin","last_synced_at":"2025-12-12T07:29:11.710Z","repository":{"id":37077321,"uuid":"205691078","full_name":"webpack/css-minimizer-webpack-plugin","owner":"webpack","description":"cssnano plugin for Webpack","archived":false,"fork":false,"pushed_at":"2025-10-09T16:58:39.000Z","size":5074,"stargazers_count":327,"open_issues_count":3,"forks_count":31,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-10-10T20:52:34.769Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webpack.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"open_collective":"webpack"}},"created_at":"2019-09-01T14:51:57.000Z","updated_at":"2025-10-09T16:58:41.000Z","dependencies_parsed_at":"2024-06-04T13:58:48.277Z","dependency_job_id":"39b0a2d6-48a7-47cf-af64-ef2bded95aba","html_url":"https://github.com/webpack/css-minimizer-webpack-plugin","commit_stats":{"total_commits":238,"total_committers":24,"mean_commits":9.916666666666666,"dds":0.7016806722689075,"last_synced_commit":"915229386cd32f22c71b09242cae164585f50fc2"},"previous_names":["lneveu/cssnano-webpack-plugin"],"tags_count":34,"template":false,"template_full_name":null,"purl":"pkg:github/webpack/css-minimizer-webpack-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fcss-minimizer-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fcss-minimizer-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fcss-minimizer-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fcss-minimizer-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webpack","download_url":"https://codeload.github.com/webpack/css-minimizer-webpack-plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fcss-minimizer-webpack-plugin/sbom","scorecard":{"id":596348,"data":{"date":"2025-07-28","repo":{"name":"github.com/webpack-contrib/css-minimizer-webpack-plugin","commit":"cc2bcddcd19dc171f052c7e61e1b40166b1399c1"},"scorecard":{"version":"v5.2.1-26-g4feedb85","commit":"4feedb857ab8d82158aa9774bf8054df41992180"},"score":6.2,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/4feedb857ab8d82158aa9774bf8054df41992180/docs/checks.md#packaging"}},{"name":"Code-Review","score":6,"reason":"Found 17/26 approved changesets -- score normalized to 6","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/4feedb857ab8d82158aa9774bf8054df41992180/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/4feedb857ab8d82158aa9774bf8054df41992180/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/4feedb857ab8d82158aa9774bf8054df41992180/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":10,"reason":"GitHub workflow tokens follow principle of least privilege","details":["Info: topLevel 'contents' permission set to 'read': .github/workflows/dependency-review.yml:5","Info: topLevel 'contents' permission set to 'read': .github/workflows/nodejs.yml:14","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/4feedb857ab8d82158aa9774bf8054df41992180/docs/checks.md#token-permissions"}},{"name":"Maintained","score":5,"reason":"6 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/4feedb857ab8d82158aa9774bf8054df41992180/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":4,"reason":"dependency not pinned by hash detected -- score normalized to 4","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/dependency-review.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/css-minimizer-webpack-plugin/dependency-review.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/dependency-review.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/css-minimizer-webpack-plugin/dependency-review.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/css-minimizer-webpack-plugin/nodejs.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/css-minimizer-webpack-plugin/nodejs.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:84: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/css-minimizer-webpack-plugin/nodejs.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:87: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/css-minimizer-webpack-plugin/nodejs.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs.yml:103: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/css-minimizer-webpack-plugin/nodejs.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/nodejs.yml:98","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   2 out of   3 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/4feedb857ab8d82158aa9774bf8054df41992180/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/4feedb857ab8d82158aa9774bf8054df41992180/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/4feedb857ab8d82158aa9774bf8054df41992180/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/4feedb857ab8d82158aa9774bf8054df41992180/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/4feedb857ab8d82158aa9774bf8054df41992180/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/4feedb857ab8d82158aa9774bf8054df41992180/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/4feedb857ab8d82158aa9774bf8054df41992180/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 26 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/4feedb857ab8d82158aa9774bf8054df41992180/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/4feedb857ab8d82158aa9774bf8054df41992180/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T23:13:53.430Z","repository_id":37077321,"created_at":"2025-08-20T23:13:53.431Z","updated_at":"2025-08-20T23:13:53.431Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279010259,"owners_count":26084719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-13T20:14:59.207Z","updated_at":"2025-12-12T07:29:11.699Z","avatar_url":"https://github.com/webpack.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/webpack/webpack\"\u003e\n    \u003cimg width=\"200\" height=\"200\" src=\"https://webpack.js.org/assets/icon-square-big.svg\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![tests][tests]][tests-url]\n[![cover][cover]][cover-url]\n[![discussion][discussion]][discussion-url]\n[![size][size]][size-url]\n\n# css-minimizer-webpack-plugin\n\nThis plugin uses [cssnano](https://cssnano.github.io/cssnano/) to optimize and minify your CSS.\n\nIt serves as a more accurate alternative to [optimize-css-assets-webpack-plugin](https://github.com/NMFR/optimize-css-assets-webpack-plugin), with better support for source maps, assets with query strings, caching, and parallel processing.\n\n## Getting Started\n\nTo begin, you'll need to install `css-minimizer-webpack-plugin`:\n\n```console\nnpm install css-minimizer-webpack-plugin --save-dev\n```\n\nor\n\n```console\nyarn add -D css-minimizer-webpack-plugin\n```\n\nor\n\n```console\npnpm add -D css-minimizer-webpack-plugin\n```\n\nThen add the plugin to your `webpack` configuration. For example:\n\n**webpack.config.js**\n\n```js\nconst CssMinimizerPlugin = require(\"css-minimizer-webpack-plugin\");\nconst MiniCssExtractPlugin = require(\"mini-css-extract-plugin\");\n\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.s?css$/,\n        use: [MiniCssExtractPlugin.loader, \"css-loader\", \"sass-loader\"],\n      },\n    ],\n  },\n  optimization: {\n    minimizer: [\n      // For webpack v5, you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line // `...`,\n      new CssMinimizerPlugin(),\n    ],\n  },\n  plugins: [new MiniCssExtractPlugin()],\n};\n```\n\n\u003e [!NOTE]\n\u003e\n\u003e This enables CSS optimization only in production mode by default.\n\nTo enable it in development mode as well, set the `optimization.minimize` option to `true`:\n\n**webpack.config.js**\n\n```js\n// [...]\nmodule.exports = {\n  optimization: {\n    // [...]\n    minimize: true,\n  },\n};\n```\n\nFinally, run Webpack using your preferred method.\n\n## Note about source maps\n\n**This plugin works only with `source-map`, `inline-source-map`, `hidden-source-map` and `nosources-source-map` values for the [`devtool`](https://webpack.js.org/configuration/devtool/) option.**\n\nWhy? Because CSS support only these source map types.\n\nThe plugin respects the [`devtool`](https://webpack.js.org/configuration/devtool/) setting and uses the `SourceMapDevToolPlugin` internally.\n\nUsing a supported `devtool` value enables source map generation.\n\nEnabling the `columns` option in `SourceMapDevToolPlugin` also allows source map generation.\n\nUse source maps to map error message locations to their original modules (note that this may slow down compilation).\n\nIf you use your own `minify` function please refer to the `minify` section for correct handling of source maps.\n\n## Options\n\n|                    Name                     |                      Type                      |              Default               | Description                                                                                      |\n| :-----------------------------------------: | :--------------------------------------------: | :--------------------------------: | :----------------------------------------------------------------------------------------------- |\n|             **[`test`](#test)**             |    `String\\|RegExp\\|Array\u003cString\\|RegExp\u003e`     |         `/\\.css(\\?.*)?$/i`         | Test to match files against.                                                                     |\n|          **[`include`](#include)**          |    `String\\|RegExp\\|Array\u003cString\\|RegExp\u003e`     |            `undefined`             | Files to include.                                                                                |\n|          **[`exclude`](#exclude)**          |    `String\\|RegExp\\|Array\u003cString\\|RegExp\u003e`     |            `undefined`             | Files to exclude.                                                                                |\n|         **[`parallel`](#parallel)**         |               `Boolean\\|Number`                |               `true`               | Enable or disable multi-process parallel running.                                                |\n|           **[`minify`](#minify)**           |          `Function\\|Array\u003cFunction\u003e`           | `CssMinimizerPlugin.cssnanoMinify` | Allows to override default minify function.                                                      |\n| **[`minimizerOptions`](#minimizeroptions)** |            `Object\\|Array\u003cObject\u003e`             |      `{ preset: 'default' }`       | Cssnano optimisations [options](https://cssnano.github.io/cssnano/docs/what-are-optimisations/). |\n|   **[`warningsFilter`](#warningsfilter)**   | `Function\u003c(warning, file, source) -\u003e Boolean\u003e` |            `() =\u003e true`            | Allows filtering of css-minimizer warnings.                                                      |\n\n### `test`\n\n- Type: `String|RegExp|Array\u003cString|RegExp\u003e`\n- Default: `/\\.css(\\?.*)?$/i`\n\nTest to match files against.\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new CssMinimizerPlugin({\n        test: /\\.foo\\.css$/i,\n      }),\n    ],\n  },\n};\n```\n\n### `include`\n\n- Type: `String|RegExp|Array\u003cString|RegExp\u003e`\n- Default: `undefined`\n\nFiles to include.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new CssMinimizerPlugin({\n        include: /\\/includes/,\n      }),\n    ],\n  },\n};\n```\n\n### `exclude`\n\n- Type: `String|RegExp|Array\u003cString|RegExp\u003e`\n- Default: `undefined`\n\nFiles to exclude.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new CssMinimizerPlugin({\n        exclude: /\\/excludes/,\n      }),\n    ],\n  },\n};\n```\n\n### `parallel`\n\n- Type: `Boolean|Number`\n- Default: `true`\n\nUse multi-process parallel running to improve the build speed.\n\nThe default number of concurrent runs: `os.cpus().length - 1` or `os.availableParallelism() - 1` (if this function is supported).\n\n\u003e ℹ️ Parallelization can speed up your build significantly and is therefore **highly recommended**.\n\u003e If a parallelization is enabled, the packages in `minimizerOptions` must be required via strings (`packageName` or `require.resolve(packageName)`). Read more in [`minimizerOptions`](#minimizeroptions)\n\n#### `Boolean`\n\nEnable or disable multi-process parallel running.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new CssMinimizerPlugin({\n        parallel: true,\n      }),\n    ],\n  },\n};\n```\n\n#### `Number`\n\nEnable multi-process parallel running and specify the number of concurrent runs.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new CssMinimizerPlugin({\n        parallel: 4,\n      }),\n    ],\n  },\n};\n```\n\n### `minify`\n\n- Type: `Function|Array\u003cFunction\u003e`\n- Default: `CssMinimizerPlugin.cssnanoMinify`\n\nOverrides the default minify function.\n\nBy default, plugin uses [cssnano](https://github.com/cssnano/cssnano) package.\n\n\u003e This is useful when using or testing unpublished versions or forks.\n\nPossible options:\n\n- `CssMinimizerPlugin.cssnanoMinify`\n- `CssMinimizerPlugin.cssoMinify`\n- `CssMinimizerPlugin.cleanCssMinify`\n- `CssMinimizerPlugin.esbuildMinify`\n- `CssMinimizerPlugin.lightningCssMinify` (previously`CssMinimizerPlugin.parcelCssMinify`, the package was renamed, but we keep it for backward compatibility)\n- `async (data, inputMap, minimizerOptions) =\u003e {return {code: \"a{color: red}\", map: \"...\", warnings: [], errors: []}}`\n\n\u003e [!WARNING]\n\u003e\n\u003e **Always use `require` inside `minify` function when `parallel` option is enabled**.\n\n#### `Function`\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new CssMinimizerPlugin({\n        minimizerOptions: {\n          level: {\n            1: {\n              roundingPrecision: \"all=3,px=5\",\n            },\n          },\n        },\n        minify: CssMinimizerPlugin.cleanCssMinify,\n      }),\n    ],\n  },\n};\n```\n\n#### `Array`\n\nIf an array of functions is passed to the `minify` option, the `minimizerOptions` must also be an array.\n\nThe function index in the `minify` array corresponds to the options object with the same index in the `minimizerOptions` array.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new CssMinimizerPlugin({\n        minimizerOptions: [\n          {}, // Options for the first function (CssMinimizerPlugin.cssnanoMinify),\n          {}, // Options for the second function (CssMinimizerPlugin.cleanCssMinify),\n          {}, // Options for the third function\n        ],\n        minify: [\n          CssMinimizerPlugin.cssnanoMinify,\n          CssMinimizerPlugin.cleanCssMinify,\n          async (data, inputMap, minimizerOptions) =\u003e\n            //  Custom minifier function\n            ({\n              code: \"a{color: red}\",\n              map: '{\"version\": \"3\", ...}',\n              warnings: [],\n              errors: [],\n            }),\n        ],\n      }),\n    ],\n  },\n};\n```\n\n### `minimizerOptions`\n\n- Type: `Object|Array\u003cObject\u003e`\n- Default: `{ preset: 'default' }`\n\nCssnano optimisations [options](https://cssnano.co/docs/what-are-optimisations/).\n\n#### `Object`\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new CssMinimizerPlugin({\n        minimizerOptions: {\n          preset: [\n            \"default\",\n            {\n              discardComments: { removeAll: true },\n            },\n          ],\n        },\n      }),\n    ],\n  },\n};\n```\n\n#### `Array`\n\nThe function index in the `minify` array corresponds to the options object with the same index in the `minimizerOptions` array.\n\nIf you use `minimizerOptions` like object, all `minify` function accept it.\n\n\u003e If parallelization is enabled, the packages in `minimizerOptions` must be referenced via strings (`packageName` or `require.resolve(packageName)`). In this case, we shouldn't use `require`/`import`.\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new CssMinimizerPlugin({\n        minimizerOptions: {\n          preset: require.resolve(\"cssnano-preset-simple\"),\n        },\n      }),\n    ],\n  },\n};\n```\n\n##### `processorOptions` (⚠ only cssnano)\n\n- Type: `Object`\n- Default: `{ from: assetName }`\n\nAllows filtering options [`processoptions`](https://postcss.org/api/#processoptions) for the cssnano.\n\nThe `parser`,` stringifier` and `syntax` can be either a function or a string indicating the module that will be imported.\n\n\u003e [!WARNING]\n\u003e\n\u003e **If any of these options are passed as a function, the `parallel` option must be disabled.**.\n\n```js\nimport sugarss from \"sugarss\";\n\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new CssMinimizerPlugin({\n        parallel: false,\n        minimizerOptions: {\n          processorOptions: {\n            parser: sugarss,\n          },\n        },\n      }),\n    ],\n  },\n};\n```\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new CssMinimizerPlugin({\n        minimizerOptions: {\n          processorOptions: {\n            parser: \"sugarss\",\n          },\n        },\n      }),\n    ],\n  },\n};\n```\n\n### `warningsFilter`\n\n- Type: `Function\u003c(warning, file, source) -\u003e Boolean\u003e`\n- Default: `() =\u003e true`\n\nFilter css-minimizer warnings (By default [cssnano](https://github.com/cssnano/cssnano)).\n\nReturn `true` to keep the warning, or a falsy value (`false`/`null`/`undefined`) to suppress it.\n\n\u003e [!WARNING]\n\u003e\n\u003e The `source` parameter will be `undefined` unless source maps are enabled.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new CssMinimizerPlugin({\n        warningsFilter: (warning, file, source) =\u003e {\n          if (/Dropping unreachable code/i.test(warning)) {\n            return true;\n          }\n\n          if (/file\\.css/i.test(file)) {\n            return true;\n          }\n\n          if (/source\\.css/i.test(source)) {\n            return true;\n          }\n\n          return false;\n        },\n      }),\n    ],\n  },\n};\n```\n\n## Examples\n\n### Use sourcemaps\n\nDon't forget to enable `sourceMap` options for all loaders.\n\n```js\nconst CssMinimizerPlugin = require(\"css-minimizer-webpack-plugin\");\n\nmodule.exports = {\n  devtool: \"source-map\",\n  module: {\n    rules: [\n      {\n        test: /\\.s?css$/,\n        use: [\n          MiniCssExtractPlugin.loader,\n          { loader: \"css-loader\", options: { sourceMap: true } },\n          { loader: \"sass-loader\", options: { sourceMap: true } },\n        ],\n      },\n    ],\n  },\n  optimization: {\n    minimizer: [new CssMinimizerPlugin()],\n  },\n  plugins: [new MiniCssExtractPlugin()],\n};\n```\n\n### Remove all comments\n\nRemove all comments, including those starting with `/*!`.\n\n```js\nmodule.exports = {\n  optimization: {\n    minimizer: [\n      new CssMinimizerPlugin({\n        minimizerOptions: {\n          preset: [\n            \"default\",\n            {\n              discardComments: { removeAll: true },\n            },\n          ],\n        },\n      }),\n    ],\n  },\n};\n```\n\n### Using custom minifier [csso](https://github.com/css/csso)\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  // Uncomment if you need source maps\n  // devtool: \"source-map\",\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new CssMinimizerPlugin({\n        minify: CssMinimizerPlugin.cssoMinify,\n        // Uncomment this line for options\n        // minimizerOptions: { restructure: false },\n      }),\n    ],\n  },\n};\n```\n\n### Using custom minifier [clean-css](https://github.com/jakubpawlowicz/clean-css)\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  // Uncomment if you need source maps\n  // devtool: \"source-map\",\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new CssMinimizerPlugin({\n        minify: CssMinimizerPlugin.cleanCssMinify,\n        // Uncomment this line for options\n        // minimizerOptions: { compatibility: 'ie11,-properties.merging' },\n      }),\n    ],\n  },\n};\n```\n\n### Using custom minifier [esbuild](https://github.com/evanw/esbuild)\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  // Uncomment if you need source maps\n  // devtool: \"source-map\",\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new CssMinimizerPlugin({\n        minify: CssMinimizerPlugin.esbuildMinify,\n      }),\n    ],\n  },\n};\n```\n\n### Using custom minifier [lightningcss](https://github.com/parcel-bundler/lightningcss), previously `@parcel/css`\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  // devtool: \"source-map\", // Uncomment for source maps\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new CssMinimizerPlugin({\n        minify: CssMinimizerPlugin.lightningCssMinify,\n        // Uncomment this line for options\n        // minimizerOptions: { targets: { ie: 11 }, drafts: { nesting: true } },\n      }),\n    ],\n  },\n};\n```\n\n### Using custom minifier [swc](https://github.com/swc-project/swc)\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  // devtool: \"source-map\", // Uncomment for source maps\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new CssMinimizerPlugin({\n        minify: CssMinimizerPlugin.swcMinify,\n        // Uncomment this line for options\n        // minimizerOptions: {},\n      }),\n    ],\n  },\n};\n```\n\n## Contributing\n\nWe welcome all contributions!\n\nIf you're new here, please take a moment to review our contributing guidelines.\n\n[CONTRIBUTING](https://github.com/webpack/css-minimizer-webpack-plugin?tab=contributing-ov-file#contributing)\n\n## License\n\n[MIT](./LICENSE)\n\n[npm]: https://img.shields.io/npm/v/css-minimizer-webpack-plugin.svg\n[npm-url]: https://npmjs.com/package/css-minimizer-webpack-plugin\n[node]: https://img.shields.io/node/v/css-minimizer-webpack-plugin.svg\n[node-url]: https://nodejs.org\n[tests]: https://github.com/webpack/css-minimizer-webpack-plugin/workflows/css-minimizer-webpack-plugin/badge.svg\n[tests-url]: https://github.com/webpack/css-minimizer-webpack-plugin/actions\n[cover]: https://codecov.io/gh/webpack/css-minimizer-webpack-plugin/branch/main/graph/badge.svg\n[cover-url]: https://codecov.io/gh/webpack/css-minimizer-webpack-plugin\n[discussion]: https://img.shields.io/github/discussions/webpack/webpack\n[discussion-url]: https://github.com/webpack/webpack/discussions\n[size]: https://packagephobia.now.sh/badge?p=css-minimizer-webpack-plugin\n[size-url]: https://packagephobia.now.sh/result?p=css-minimizer-webpack-plugin\n","funding_links":["https://opencollective.com/webpack"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack%2Fcss-minimizer-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebpack%2Fcss-minimizer-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack%2Fcss-minimizer-webpack-plugin/lists"}