{"id":49843294,"url":"https://github.com/webpack/minimizer-webpack-plugin","last_synced_at":"2026-06-04T10:01:06.333Z","repository":{"id":32809917,"uuid":"143057914","full_name":"webpack/minimizer-webpack-plugin","owner":"webpack","description":"Minimizer Plugin","archived":false,"fork":false,"pushed_at":"2026-05-27T17:54:01.000Z","size":6266,"stargazers_count":1961,"open_issues_count":7,"forks_count":166,"subscribers_count":18,"default_branch":"main","last_synced_at":"2026-05-28T10:04:06.715Z","etag":null,"topics":["minify","minimizer","terser","uglify","webpack","webpack-plugin"],"latest_commit_sha":null,"homepage":"","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":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"open_collective":"webpack"}},"created_at":"2018-07-31T19:25:19.000Z","updated_at":"2026-05-27T17:30:46.000Z","dependencies_parsed_at":"2026-03-01T08:10:24.406Z","dependency_job_id":null,"html_url":"https://github.com/webpack/minimizer-webpack-plugin","commit_stats":{"total_commits":341,"total_committers":36,"mean_commits":9.472222222222221,"dds":0.6041055718475073,"last_synced_commit":"6eebdf76b5d172cb226fc7f061a89e58d9c17425"},"previous_names":["webpack-contrib/terser-webpack-plugin","webpack/minimizer-webpack-plugin","webpack/terser-webpack-plugin"],"tags_count":88,"template":false,"template_full_name":null,"purl":"pkg:github/webpack/minimizer-webpack-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fminimizer-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fminimizer-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fminimizer-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fminimizer-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webpack","download_url":"https://codeload.github.com/webpack/minimizer-webpack-plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fminimizer-webpack-plugin/sbom","scorecard":{"id":906427,"data":{"date":"2025-07-28","repo":{"name":"github.com/webpack-contrib/terser-webpack-plugin","commit":"c46400acff727a1138ec619fc3d6c0dfadfd3e37"},"scorecard":{"version":"v5.2.1-26-g4feedb85","commit":"4feedb857ab8d82158aa9774bf8054df41992180"},"score":5.9,"checks":[{"name":"Code-Review","score":5,"reason":"Found 14/26 approved changesets -- score normalized to 5","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":"Maintained","score":6,"reason":"6 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 6","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/4feedb857ab8d82158aa9774bf8054df41992180/docs/checks.md#maintained"}},{"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":"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":"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":"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":"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":"Pinned-Dependencies","score":3,"reason":"dependency not pinned by hash detected -- score normalized to 3","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/terser-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/terser-webpack-plugin/dependency-review.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/terser-webpack-plugin/nodejs.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:85: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/terser-webpack-plugin/nodejs.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:96: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/terser-webpack-plugin/nodejs.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs.yml:113: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/terser-webpack-plugin/nodejs.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/terser-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/terser-webpack-plugin/nodejs.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/nodejs.yml:108","Info:   0 out of   7 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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 25 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":7,"reason":"3 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv"],"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-24T17:31:34.280Z","repository_id":32809917,"created_at":"2025-08-24T17:31:34.280Z","updated_at":"2025-08-24T17:31:34.280Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33839645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-02T02:00:07.132Z","response_time":109,"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":["minify","minimizer","terser","uglify","webpack","webpack-plugin"],"created_at":"2026-05-14T08:01:25.718Z","updated_at":"2026-06-04T10:01:06.276Z","avatar_url":"https://github.com/webpack.png","language":"JavaScript","funding_links":["https://opencollective.com/webpack"],"categories":[],"sub_categories":[],"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# minimizer-webpack-plugin\n\nThis plugin minifies your assets in a webpack build. It ships with several\nbuilt-in minimizers covering JavaScript, JSON, HTML, and CSS — pick one\nwith the [`minify`](#minify) option and target the right files with\n[`test`](#test).\n\nJavaScript minimizers:\n\n- [`terser`](https://github.com/terser/terser) — `MinimizerPlugin.terserMinify` (default). The same JavaScript-based minifier that webpack uses out of the box; produces small, well-tested output and supports the full set of `extractComments` modes.\n- [`uglify-js`](https://github.com/mishoo/UglifyJS) — `MinimizerPlugin.uglifyJsMinify`. ES5-only minifier, useful when you specifically need UglifyJS-compatible output. Requires `npm install --save-dev uglify-js`.\n- [`@swc/core`](https://github.com/swc-project/swc) — `MinimizerPlugin.swcMinify`. A very fast Rust-based JavaScript/TypeScript minifier. Requires `npm install --save-dev @swc/core`.\n- [`esbuild`](https://github.com/evanw/esbuild) — `MinimizerPlugin.esbuildMinify`. An extremely fast JS bundler/minifier; legal comments are always preserved (no `extractComments` support). Requires `npm install --save-dev esbuild`.\n\nJSON minimizer:\n\n- `JSON.stringify` — `MinimizerPlugin.jsonMinify`. Built in (no extra dependency); supports `space` and `replacer` options.\n\nHTML minimizers:\n\n- [`html-minifier-terser`](https://github.com/terser/html-minifier-terser) — `MinimizerPlugin.htmlMinifierTerser`. The default HTML minimizer. JavaScript-based, no native dependency. Requires `npm install --save-dev html-minifier-terser`.\n- [`@swc/html`](https://github.com/swc-project/swc) — `MinimizerPlugin.swcMinifyHtml` (full HTML documents) and `MinimizerPlugin.swcMinifyHtmlFragment` (HTML fragments, e.g. `\u003ctemplate\u003e` content). Very fast Rust-based platform for the Web. Requires `npm install --save-dev @swc/html`.\n- [`@minify-html/node`](https://github.com/wilsonzlin/minify-html) — `MinimizerPlugin.minifyHtmlNode`. A Rust HTML minifier optimised for speed and effectiveness. Requires `npm install --save-dev @minify-html/node`.\n\nCSS minimizers:\n\n- [`cssnano`](https://cssnano.github.io/cssnano/) — `MinimizerPlugin.cssnanoMinify`. The default CSS minimizer. Built on top of [PostCSS](https://postcss.org/). Requires `npm install --save-dev cssnano postcss`.\n- [`csso`](https://github.com/css/csso) — `MinimizerPlugin.cssoMinify`. A CSS minifier with structural optimisations. Requires `npm install --save-dev csso`.\n- [`clean-css`](https://github.com/clean-css/clean-css) — `MinimizerPlugin.cleanCssMinify`. A widely-used CSS optimiser. Requires `npm install --save-dev clean-css`.\n- [`esbuild`](https://github.com/evanw/esbuild) — `MinimizerPlugin.esbuildMinifyCss`. Very fast CSS minification using esbuild's CSS loader. Requires `npm install --save-dev esbuild`.\n- [`lightningcss`](https://github.com/parcel-bundler/lightningcss) — `MinimizerPlugin.lightningCssMinify`. A Rust-based CSS parser, transformer, and minifier. Requires `npm install --save-dev lightningcss`.\n- [`@swc/css`](https://github.com/swc-project/swc) — `MinimizerPlugin.swcMinifyCss`. A very fast Rust-based CSS minifier. Requires `npm install --save-dev @swc/css`.\n\nAll of the non-default minimizers are declared as **optional** peer\ndependencies — install only the ones you actually use. You can also stack\nmultiple `MinimizerPlugin` instances in the same build to handle different\nfile types with different minimizers (see [Examples](#examples)).\n\n## Getting Started\n\nWebpack v5 comes with the latest `minimizer-webpack-plugin` out of the box.\nIf you are using Webpack v5 or above and wish to customize the options, you will still need to install `minimizer-webpack-plugin`.\nUsing Webpack v4, you have to install `terser-webpack-plugin` v4 (`minimizer-webpack-plugin` is only published for Webpack v5+).\n\nTo begin, you'll need to install `minimizer-webpack-plugin`:\n\n```console\nnpm install minimizer-webpack-plugin --save-dev\n```\n\nor\n\n```console\nyarn add -D minimizer-webpack-plugin\n```\n\nor\n\n```console\npnpm add -D minimizer-webpack-plugin\n```\n\nThen add the plugin to your `webpack` configuration. For example:\n\n**webpack.config.js**\n\n```js\nconst MinimizerPlugin = require(\"minimizer-webpack-plugin\");\n\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [new MinimizerPlugin()],\n  },\n};\n```\n\nFinally, run `webpack` using the method you normally use (e.g., via CLI or an npm script).\n\n## Note about source maps\n\n**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?\n\n- `eval` wraps modules in `eval(\"string\")` and the minimizer does not handle strings.\n- `cheap` has no column information and the minimizer generates only a single line, which leaves only a single mapping.\n\nUsing supported `devtool` values enable source map generation.\n\n## Options\n\n- **[`test`](#test)**\n- **[`include`](#include)**\n- **[`exclude`](#exclude)**\n- **[`parallel`](#parallel)**\n- **[`minify`](#minify)**\n- **[`minimizerOptions`](#minimizeroptions)**\n- **[`extractComments`](#extractcomments)**\n\n### `test`\n\nType:\n\n```ts\ntype test = string | RegExp | (string | RegExp)[];\n```\n\nDefault: `/\\.m?js(\\?.*)?$/i`\n\nTest to match files against.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        test: /\\.js(\\?.*)?$/i,\n      }),\n    ],\n  },\n};\n```\n\n### `include`\n\nType:\n\n```ts\ntype include = string | RegExp | (string | RegExp)[];\n```\n\nDefault: `undefined`\n\nFiles to include.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        include: /\\/includes/,\n      }),\n    ],\n  },\n};\n```\n\n### `exclude`\n\nType:\n\n```ts\ntype exclude = string | RegExp | (string | RegExp)[];\n```\n\nDefault: `undefined`\n\nFiles to exclude.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        exclude: /\\/excludes/,\n      }),\n    ],\n  },\n};\n```\n\n### `parallel`\n\nType:\n\n```ts\ntype parallel = boolean | number;\n```\n\nDefault: `true`\n\nUse multi-process parallel running to improve the build speed.\n\nDefault number of concurrent runs: `os.cpus().length - 1` or `os.availableParallelism() - 1` (if this function is supported).\n\n\u003e **Note**\n\u003e\n\u003e Parallelization can speedup your build significantly and is therefore **highly recommended**.\n\n\u003e **Warning**\n\u003e\n\u003e If you use **Circle CI** or any other environment that doesn't provide the real available count of CPUs then you need to explicitly set up the number of CPUs to avoid `Error: Call retries were exceeded` (see [#143](https://github.com/webpack/minimizer-webpack-plugin/issues/143), [#202](https://github.com/webpack/minimizer-webpack-plugin/issues/202)).\n\n#### `boolean`\n\nEnable/disable multi-process parallel running.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        parallel: true,\n      }),\n    ],\n  },\n};\n```\n\n#### `number`\n\nEnable multi-process parallel running and set number of concurrent runs.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        parallel: 4,\n      }),\n    ],\n  },\n};\n```\n\n### `minify`\n\nType:\n\n```ts\ntype minifyFn = (\n  input: Record\u003cstring, string\u003e,\n  sourceMap: import(\"@jridgewell/trace-mapping\").SourceMapInput | undefined,\n  minifyOptions: {\n    module?: boolean | undefined;\n    ecma?: import(\"terser\").ECMA | undefined;\n  },\n  extractComments:\n    | boolean\n    | \"all\"\n    | \"some\"\n    | RegExp\n    | ((\n        astNode: any,\n        comment: {\n          value: string;\n          type: \"comment1\" | \"comment2\" | \"comment3\" | \"comment4\";\n          pos: number;\n          line: number;\n          col: number;\n        },\n      ) =\u003e boolean)\n    | {\n        condition?:\n          | boolean\n          | \"all\"\n          | \"some\"\n          | RegExp\n          | ((\n              astNode: any,\n              comment: {\n                value: string;\n                type: \"comment1\" | \"comment2\" | \"comment3\" | \"comment4\";\n                pos: number;\n                line: number;\n                col: number;\n              },\n            ) =\u003e boolean)\n          | undefined;\n        filename?: string | ((fileData: any) =\u003e string) | undefined;\n        banner?:\n          | string\n          | boolean\n          | ((commentsFile: string) =\u003e string)\n          | undefined;\n      }\n    | undefined,\n) =\u003e Promise\u003c{\n  code: string;\n  map?: import(\"@jridgewell/trace-mapping\").SourceMapInput | undefined;\n  errors?: (string | Error)[] | undefined;\n  warnings?: (string | Error)[] | undefined;\n  extractedComments?: string[] | undefined;\n}\u003e;\n\ntype minify = minifyFn | minifyFn[];\n```\n\nDefault: `MinimizerPlugin.terserMinify`\n\nAllows you to override the default minify function.\nBy default plugin uses [terser](https://github.com/terser/terser) package.\nUseful for using and testing unpublished versions or forks.\n\nAn array of functions can also be provided. Each minimizer can expose a\n`filter(name, info)` helper that decides whether it should run on a given\nasset; the plugin dispatches each asset only to the minimizers whose `filter`\naccepts it (or runs them all when no filter is set). All built-in minimizers\nship with a `filter` that matches their natural extension, so a single plugin\ninstance and a single worker pool can handle JS, CSS, HTML and JSON together\nwithout juggling multiple `MinimizerPlugin` instances — just widen `test` to\nlet those asset types reach the dispatcher:\n\n```js\nnew MinimizerPlugin({\n  test: /\\.(?:[cm]?js|css|html?|json)(\\?.*)?$/i,\n  minify: [\n    MinimizerPlugin.terserMinify,\n    MinimizerPlugin.cssnanoMinify,\n    MinimizerPlugin.htmlMinifierTerser,\n    MinimizerPlugin.jsonMinify,\n  ],\n});\n```\n\nWhen more than one minimizer in the array claims the same asset, the chain\nsemantic still applies: the output of each accepting minimizer is fed as\ninput to the next. The [`minimizerOptions`](#minimizeroptions) option may\nbe an array (index-paired with `minify`) or a single object reused by every\nminimizer.\n\nThe `test` option always defaults to `/\\.[cm]?js(\\?.*)?$/i`. When you mix\nasset types in a single plugin instance, widen `test` so non-JS assets reach\nthe dispatcher (for example `test: /\\.(?:[cm]?js|css|html?|json)(\\?.*)?$/i`).\n\n\u003e **Warning**\n\u003e\n\u003e **Always use `require` inside `minify` function when `parallel` option enabled**.\n\n#### `function`\n\n**webpack.config.js**\n\n```js\n// Can be async\nconst minify = (input, sourceMap, minimizerOptions, extractsComments) =\u003e {\n  // The `minimizerOptions` argument contains options from the `minimizerOptions` plugin option\n  // You can use `minimizerOptions.myCustomOption`\n\n  // Custom logic for extract comments\n  const { map, code } = require(\"uglify-module\") // Or require('./path/to/uglify-module')\n    .minify(input, {\n      /* Your options for minification */\n    });\n\n  return { map, code, warnings: [], errors: [], extractedComments: [] };\n};\n\n// Used to regenerate `fullhash`/`chunkhash` between different implementation\n// Example: you fix a bug in custom minimizer/custom function, but unfortunately webpack doesn't know about it, so you will get the same fullhash/chunkhash\n// to avoid this you can provide version of your custom minimizer\n// You don't need if you use only `contenthash`\nminify.getMinimizerVersion = () =\u003e {\n  let packageJson;\n\n  try {\n    packageJson = require(\"uglify-module/package.json\");\n  } catch (error) {\n    // Ignore\n  }\n\n  return packageJson \u0026\u0026 packageJson.version;\n};\n\n// Restrict the minimizer to the assets it can actually handle. The plugin\n// skips assets for which `filter` returns `false` and (when an array of\n// minimizers is used) dispatches each asset only to the minimizers that\n// accept it. Returning `undefined` is treated as accept.\nminify.filter = (name) =\u003e /\\.[cm]?js(\\?.*)?$/i.test(name);\n\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        minimizerOptions: {\n          myCustomOption: true,\n        },\n        minify,\n      }),\n    ],\n  },\n};\n```\n\n#### `array`\n\nIf an array of functions is passed to the `minify` option, each asset is\ndispatched to the minimizers whose `filter` accepts it. When more than one\nminimizer accepts the same asset the output of each is fed as input to the\nnext one (the chain semantic). The `minimizerOptions` option can be either an\narray of option objects (index-paired with `minify`) or a single object that\nwill be shared by all minimizers. Warnings, errors and extracted comments\nfrom all running minimizers are merged together.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        minify: [MinimizerPlugin.terserMinify, MinimizerPlugin.swcMinify],\n        // `minimizerOptions` can be an array of options, one per `minify` entry\n        minimizerOptions: [\n          // Options for `MinimizerPlugin.terserMinify`\n          { mangle: false },\n          // Options for `MinimizerPlugin.swcMinify`\n          {},\n        ],\n      }),\n    ],\n  },\n};\n```\n\nA single plugin instance can also handle multiple asset types — the built-in\nminimizers each ship with a `filter` matching their natural extension, so JS,\nCSS, HTML and JSON can all be minified by one shared worker pool:\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        // `test` still defaults to JS only, so widen it to catch every\n        // asset type you want the dispatcher to consider.\n        test: /\\.(?:[cm]?js|css|html?|json)(\\?.*)?$/i,\n        minify: [\n          MinimizerPlugin.terserMinify,\n          MinimizerPlugin.cssnanoMinify,\n          MinimizerPlugin.htmlMinifierTerser,\n          MinimizerPlugin.jsonMinify,\n        ],\n      }),\n    ],\n  },\n};\n```\n\n### `minimizerOptions`\n\nType:\n\n```ts\ninterface minimizerOptions {\n  compress?: boolean | CompressOptions;\n  ecma?: ECMA;\n  enclose?: boolean | string;\n  ie8?: boolean;\n  keep_classnames?: boolean | RegExp;\n  keep_fnames?: boolean | RegExp;\n  mangle?: boolean | MangleOptions;\n  module?: boolean;\n  nameCache?: object;\n  format?: FormatOptions;\n  /** @deprecated */\n  output?: FormatOptions;\n  parse?: ParseOptions;\n  safari10?: boolean;\n  sourceMap?: boolean | SourceMapOptions;\n  toplevel?: boolean;\n}\n\ntype options = minimizerOptions | minimizerOptions[];\n```\n\nDefault: [default](https://github.com/terser/terser#minify-options)\n\nOptions for the active minimizer. With the default Terser minify, see Terser's\n[minify options](https://github.com/terser/terser#minify-options).\n\nWhen the [`minify`](#minify) option is an array of minimizers, `minimizerOptions`\ncan also be an array. Each element is passed to the minimizer at the same\nindex in the `minify` array. If a single object is provided instead, it is\nreused for every minimizer.\n\n\u003e **Note**\n\u003e\n\u003e `terserOptions` is kept as a deprecated alias of `minimizerOptions` for\n\u003e backwards compatibility — passing either is equivalent. If both are set,\n\u003e `minimizerOptions` wins. Prefer `minimizerOptions` in new code.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        minimizerOptions: {\n          ecma: undefined,\n          parse: {},\n          compress: {},\n          mangle: true, // Note `mangle.properties` is `false` by default.\n          module: false,\n          // Deprecated\n          output: null,\n          format: null,\n          toplevel: false,\n          nameCache: null,\n          ie8: false,\n          keep_classnames: undefined,\n          keep_fnames: false,\n          safari10: false,\n        },\n      }),\n    ],\n  },\n};\n```\n\n### `extractComments`\n\nType:\n\n```ts\ntype extractComments =\n  | boolean\n  | string\n  | RegExp\n  | ((\n      astNode: any,\n      comment: {\n        value: string;\n        type: \"comment1\" | \"comment2\" | \"comment3\" | \"comment4\";\n        pos: number;\n        line: number;\n        col: number;\n      },\n    ) =\u003e boolean)\n  | {\n      condition?:\n        | boolean\n        | \"all\"\n        | \"some\"\n        | RegExp\n        | ((\n            astNode: any,\n            comment: {\n              value: string;\n              type: \"comment1\" | \"comment2\" | \"comment3\" | \"comment4\";\n              pos: number;\n              line: number;\n              col: number;\n            },\n          ) =\u003e boolean)\n        | undefined;\n      filename?: string | ((fileData: any) =\u003e string) | undefined;\n      banner?:\n        | string\n        | boolean\n        | ((commentsFile: string) =\u003e string)\n        | undefined;\n    };\n```\n\nDefault: `true`\n\nWhether comments shall be extracted to a separate file, (see [details](https://github.com/webpack/webpack/commit/71933e979e51c533b432658d5e37917f9e71595a)).\n\nBy default, extract only comments using `/^\\**!|@preserve|@license|@cc_on/i` RegExp condition and remove remaining comments.\n\nIf the original file is named `foo.js`, then the comments will be stored to `foo.js.LICENSE.txt`.\n\nThe `minimizerOptions.format.comments` option specifies whether the comment will be preserved - i.e., it is possible to preserve some comments (e.g. annotations) while extracting others, or even preserve comments that have already been extracted.\n\n#### `boolean`\n\nEnable/disable extracting comments.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        extractComments: true,\n      }),\n    ],\n  },\n};\n```\n\n#### `string`\n\nExtract `all` or `some` (use the `/^\\**!|@preserve|@license|@cc_on/i` RegExp) comments.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        extractComments: \"all\",\n      }),\n    ],\n  },\n};\n```\n\n#### `RegExp`\n\nAll comments that match the given expression will be extracted to a separate file.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        extractComments: /@extract/i,\n      }),\n    ],\n  },\n};\n```\n\n#### `function`\n\nAll comments that match the given expression will be extracted to a separate file.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        extractComments: (astNode, comment) =\u003e {\n          if (/@extract/i.test(comment.value)) {\n            return true;\n          }\n\n          return false;\n        },\n      }),\n    ],\n  },\n};\n```\n\n#### `object`\n\nAllows you to customize condition for extracting comments, and specify the extracted file name and banner.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        extractComments: {\n          condition: /^\\**!|@preserve|@license|@cc_on/i,\n          filename: (fileData) =\u003e\n            // The \"fileData\" argument contains object with \"filename\", \"basename\", \"query\" and \"hash\"\n            `${fileData.filename}.LICENSE.txt${fileData.query}`,\n          banner: (licenseFile) =\u003e\n            `License information can be found in ${licenseFile}`,\n        },\n      }),\n    ],\n  },\n};\n```\n\n##### `condition`\n\nType:\n\n```ts\ntype condition =\n  | boolean\n  | \"all\"\n  | \"some\"\n  | RegExp\n  | ((\n      astNode: any,\n      comment: {\n        value: string;\n        type: \"comment1\" | \"comment2\" | \"comment3\" | \"comment4\";\n        pos: number;\n        line: number;\n        col: number;\n      },\n    ) =\u003e boolean)\n  | undefined;\n```\n\nThe condition that determines which comments should be extracted.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        extractComments: {\n          condition: \"some\",\n          filename: (fileData) =\u003e\n            // The \"fileData\" argument contains object with \"filename\", \"basename\", \"query\" and \"hash\"\n            `${fileData.filename}.LICENSE.txt${fileData.query}`,\n          banner: (licenseFile) =\u003e\n            `License information can be found in ${licenseFile}`,\n        },\n      }),\n    ],\n  },\n};\n```\n\n##### `filename`\n\nType:\n\n```ts\ntype filename = string | ((fileData: any) =\u003e string) | undefined;\n```\n\nDefault: `[file].LICENSE.txt[query]`\n\nAvailable placeholders: `[file]`, `[query]` and `[filebase]` (`[base]` for webpack 5).\n\nThe file where the extracted comments will be stored.\n\nDefault is to append the suffix `.LICENSE.txt` to the original filename.\n\n\u003e **Warning**\n\u003e\n\u003e We highly recommend using the `.txt` extension. Using `.js`/`.cjs`/`.mjs` extensions may conflict with existing assets, which leads to broken code.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        extractComments: {\n          condition: /^\\**!|@preserve|@license|@cc_on/i,\n          filename: \"extracted-comments.js\",\n          banner: (licenseFile) =\u003e\n            `License information can be found in ${licenseFile}`,\n        },\n      }),\n    ],\n  },\n};\n```\n\n##### `banner`\n\nType:\n\n```ts\ntype banner = string | boolean | ((commentsFile: string) =\u003e string) | undefined;\n```\n\nDefault: `/*! For license information please see ${commentsFile} */`\n\nThe banner text that points to the extracted file and will be added at the top of the original file.\n\nIt can be `false` (no banner), a `String`, or a `function\u003c(string) -\u003e String\u003e` that will be called with the filename where the extracted comments have been stored.\n\nThe banner will be wrapped in a comment.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        extractComments: {\n          condition: true,\n          filename: (fileData) =\u003e\n            // The \"fileData\" argument contains object with \"filename\", \"basename\", \"query\" and \"hash\"\n            `${fileData.filename}.LICENSE.txt${fileData.query}`,\n          banner: (commentsFile) =\u003e\n            `My custom banner about license information ${commentsFile}`,\n        },\n      }),\n    ],\n  },\n};\n```\n\n## Examples\n\n### Preserve Comments\n\nExtract all legal comments (i.e. `/^\\**!|@preserve|@license|@cc_on/i`) and preserve `/@license/i` comments.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        minimizerOptions: {\n          format: {\n            comments: /@license/i,\n          },\n        },\n        extractComments: true,\n      }),\n    ],\n  },\n};\n```\n\n### Remove Comments\n\nIf you want to build without comments, use this config:\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        minimizerOptions: {\n          format: {\n            comments: false,\n          },\n        },\n        extractComments: false,\n      }),\n    ],\n  },\n};\n```\n\n### [`uglify-js`](https://github.com/mishoo/UglifyJS)\n\n[`UglifyJS`](https://github.com/mishoo/UglifyJS) is a JavaScript parser, minifier, compressor and beautifier toolkit.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        minify: MinimizerPlugin.uglifyJsMinify,\n        // `minimizerOptions` will be passed to `uglify-js`\n        // Link to options - https://github.com/mishoo/UglifyJS#minify-options\n        minimizerOptions: {},\n      }),\n    ],\n  },\n};\n```\n\n### [`swc`](https://github.com/swc-project/swc)\n\n[`swc`](https://github.com/swc-project/swc) is a super-fast compiler written in `Rust`, producing widely supported JavaScript from modern standards and TypeScript.\n\n\u003e **Warning**\n\u003e\n\u003e `extractComments` is supported with `@swc/core \u003e= 1.15.30`.\n\u003e Only serializable extract conditions are supported: booleans, `\"some\"`, `\"all\"`, string patterns, `RegExp` values without flags, or object conditions that resolve to those forms.\n\u003e Function conditions and flagged regular expressions are not supported.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        minify: MinimizerPlugin.swcMinify,\n        // `minimizerOptions` will be passed to `swc` (`@swc/core`)\n        // Link to options - https://swc.rs/docs/config-js-minify\n        minimizerOptions: {},\n      }),\n    ],\n  },\n};\n```\n\n### [`esbuild`](https://github.com/evanw/esbuild)\n\n[`esbuild`](https://github.com/evanw/esbuild) is an extremely fast JavaScript bundler and minifier.\n\n\u003e **Warning**\n\u003e\n\u003e The `extractComments` option is not supported, and all legal comments (i.e. copyright, licenses and etc) will be preserved.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        minify: MinimizerPlugin.esbuildMinify,\n        // `minimizerOptions` will be passed to `esbuild`\n        // Link to options - https://esbuild.github.io/api/#minify\n        // Note: the `minify` options is true by default (and override other `minify*` options), so if you want to disable the `minifyIdentifiers` option (or other `minify*` options) please use:\n        // minimizerOptions: {\n        //   minify: false,\n        //   minifyWhitespace: true,\n        //   minifyIdentifiers: false,\n        //   minifySyntax: true,\n        // },\n        minimizerOptions: {},\n      }),\n    ],\n  },\n};\n```\n\n### JSON\n\nUses `JSON.stringify()` to minify your JSON files during the build process.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      // Keeps original terser plugin to minify JS files\n      \"...\",\n      // Will minify JSON files (they can come from copy-webpack-plugin or when you are using asset modules)\n      new MinimizerPlugin({\n        test: /\\.json$/,\n        minify: MinimizerPlugin.jsonMinify,\n        // We are supporting `space` and `replacer` options, you can set them below\n        minimizerOptions: {},\n      }),\n    ],\n  },\n};\n```\n\n### HTML\n\nThe plugin can minify HTML assets too. Pick one of the bundled HTML\nminimizers and set `test` to match your HTML files.\n\nAvailable HTML minimizers:\n\n- `MinimizerPlugin.htmlMinifierTerser` — uses [`html-minifier-terser`](https://github.com/terser/html-minifier-terser).\n- `MinimizerPlugin.swcMinifyHtml` — uses [`@swc/html`](https://github.com/swc-project/swc) for full HTML documents (with doctype and `\u003chtml\u003e`/`\u003chead\u003e`/`\u003cbody\u003e` tags).\n- `MinimizerPlugin.swcMinifyHtmlFragment` — uses [`@swc/html`](https://github.com/swc-project/swc) for HTML fragments (e.g. content inside `\u003ctemplate\u003e\u003c/template\u003e` or partial HTML strings).\n- `MinimizerPlugin.minifyHtmlNode` — uses [`@minify-html/node`](https://github.com/wilsonzlin/minify-html).\n\nThe HTML minimizers are optional peer dependencies — install only the one\nyou actually use:\n\n```console\nnpm install --save-dev html-minifier-terser\n# or\nnpm install --save-dev @swc/html\n# or\nnpm install --save-dev @minify-html/node\n```\n\n\u003e **Note**\n\u003e\n\u003e HTML assets typically come from plugins like\n\u003e [`copy-webpack-plugin`](https://github.com/webpack-contrib/copy-webpack-plugin),\n\u003e [`html-webpack-plugin`](https://github.com/jantimon/html-webpack-plugin),\n\u003e or webpack's [asset modules](https://webpack.js.org/guides/asset-modules/).\n\n\u003e **Note**\n\u003e\n\u003e Whitespace handling differs between tools (defaults):\n\u003e\n\u003e - `@swc/html` — removes/collapses whitespace only in safe places (around `html`/`body`, inside `\u003chead\u003e`, between `\u003cmeta\u003e`/`\u003cscript\u003e`/`\u003clink\u003e` etc.).\n\u003e - `html-minifier-terser` — always collapses multiple whitespaces to a single space (never removes entirely); configurable via [its options](https://github.com/terser/html-minifier-terser#options-quick-reference).\n\u003e - `@minify-html/node` — see [its whitespace docs](https://github.com/wilsonzlin/minify-html#whitespace).\n\n#### `html-minifier-terser`\n\n[`html-minifier-terser`](https://github.com/terser/html-minifier-terser) is a JavaScript-based HTML minifier with no native dependency. It's the default HTML minimizer.\n\n**webpack.config.js**\n\n```js\nconst MinimizerPlugin = require(\"minimizer-webpack-plugin\");\n\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      // Keeps the default Terser plugin for JS files\n      \"...\",\n      new MinimizerPlugin({\n        test: /\\.html(\\?.*)?$/i,\n        minify: MinimizerPlugin.htmlMinifierTerser,\n        // Options - https://github.com/terser/html-minifier-terser#options-quick-reference\n        minimizerOptions: {\n          collapseWhitespace: true,\n          removeComments: true,\n        },\n      }),\n    ],\n  },\n};\n```\n\n#### `@swc/html` — HTML documents\n\nUse `swcMinifyHtml` for complete HTML documents (i.e. with a doctype and `\u003chtml\u003e`/`\u003chead\u003e`/`\u003cbody\u003e` tags).\n\n**webpack.config.js**\n\n```js\nconst MinimizerPlugin = require(\"minimizer-webpack-plugin\");\n\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      \"...\",\n      new MinimizerPlugin({\n        test: /\\.html(\\?.*)?$/i,\n        minify: MinimizerPlugin.swcMinifyHtml,\n        // Options - https://github.com/swc-project/bindings/blob/main/packages/html/index.ts\n        minimizerOptions: {},\n      }),\n    ],\n  },\n};\n```\n\n#### `@swc/html` — HTML fragments\n\nUse `swcMinifyHtmlFragment` for partial HTML — for example, content of `\u003ctemplate\u003e\u003c/template\u003e` tags or HTML strings that get injected into another document.\n\n**webpack.config.js**\n\n```js\nconst MinimizerPlugin = require(\"minimizer-webpack-plugin\");\n\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      \"...\",\n      new MinimizerPlugin({\n        test: /\\.template\\.html$/i,\n        minify: MinimizerPlugin.swcMinifyHtmlFragment,\n        // Options - https://github.com/swc-project/bindings/blob/main/packages/html/index.ts\n        minimizerOptions: {},\n      }),\n    ],\n  },\n};\n```\n\n\u003e **Note**\n\u003e\n\u003e The difference between `swcMinifyHtml` and `swcMinifyHtmlFragment` is the\n\u003e error reporting — invalid or broken syntax is reported at build time.\n\n#### `@minify-html/node`\n\n[`@minify-html/node`](https://github.com/wilsonzlin/minify-html) is a Rust HTML minifier.\n\n**webpack.config.js**\n\n```js\nconst Minimizer = require(\"minimizer-webpack-plugin\");\n\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      \"...\",\n      new Minimizer({\n        test: /\\.html(\\?.*)?$/i,\n        minify: Minimizer.minifyHtmlNode,\n        // Options - https://github.com/wilsonzlin/minify-html#minification\n        minimizerOptions: {},\n      }),\n    ],\n  },\n};\n```\n\nYou can also stack multiple `MinimizerPlugin` instances to compress different files with different `minify` functions in the same build (e.g. JS with `terserMinify`, HTML with `htmlMinifierTerser`, JSON with `jsonMinify`).\n\n### CSS\n\nThe plugin can minify CSS assets too. Pick one of the bundled CSS\nminimizers and set `test` to match your CSS files.\n\nAvailable CSS minimizers:\n\n- `MinimizerPlugin.cssnanoMinify` — uses [`cssnano`](https://cssnano.github.io/cssnano/) (via [`postcss`](https://postcss.org/)).\n- `MinimizerPlugin.cssoMinify` — uses [`csso`](https://github.com/css/csso).\n- `MinimizerPlugin.cleanCssMinify` — uses [`clean-css`](https://github.com/clean-css/clean-css).\n- `MinimizerPlugin.esbuildMinifyCss` — uses [`esbuild`](https://github.com/evanw/esbuild) with the CSS loader.\n- `MinimizerPlugin.lightningCssMinify` — uses [`lightningcss`](https://github.com/parcel-bundler/lightningcss).\n- `MinimizerPlugin.swcMinifyCss` — uses [`@swc/css`](https://github.com/swc-project/swc).\n\nThe CSS minimizers are optional peer dependencies — install only the ones\nyou actually use:\n\n```console\nnpm install --save-dev cssnano postcss\n# or\nnpm install --save-dev csso\n# or\nnpm install --save-dev clean-css\n# or\nnpm install --save-dev esbuild\n# or\nnpm install --save-dev lightningcss\n# or\nnpm install --save-dev @swc/css\n```\n\n\u003e **Note**\n\u003e\n\u003e CSS assets typically come from plugins like\n\u003e [`mini-css-extract-plugin`](https://github.com/webpack-contrib/mini-css-extract-plugin)\n\u003e or webpack's [asset modules](https://webpack.js.org/guides/asset-modules/).\n\n#### `cssnano`\n\n[`cssnano`](https://cssnano.github.io/cssnano/) is the default CSS minimizer. It runs as a [PostCSS](https://postcss.org/) plugin.\n\n**webpack.config.js**\n\n```js\nconst MinimizerPlugin = require(\"minimizer-webpack-plugin\");\n\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      // Keeps the default Terser plugin for JS files\n      \"...\",\n      new MinimizerPlugin({\n        test: /\\.css(\\?.*)?$/i,\n        minify: MinimizerPlugin.cssnanoMinify,\n        // Options - https://cssnano.github.io/cssnano/docs/config-file/\n        minimizerOptions: {\n          preset: \"default\",\n        },\n      }),\n    ],\n  },\n};\n```\n\n#### `csso`\n\n[`csso`](https://github.com/css/csso) is a CSS minifier with structural optimisations.\n\n**webpack.config.js**\n\n```js\nconst MinimizerPlugin = require(\"minimizer-webpack-plugin\");\n\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      \"...\",\n      new MinimizerPlugin({\n        test: /\\.css(\\?.*)?$/i,\n        minify: MinimizerPlugin.cssoMinify,\n        // Options - https://github.com/css/csso#minifysource-options\n        minimizerOptions: {},\n      }),\n    ],\n  },\n};\n```\n\n#### `clean-css`\n\n[`clean-css`](https://github.com/clean-css/clean-css) is a widely-used CSS optimiser.\n\n**webpack.config.js**\n\n```js\nconst MinimizerPlugin = require(\"minimizer-webpack-plugin\");\n\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      \"...\",\n      new MinimizerPlugin({\n        test: /\\.css(\\?.*)?$/i,\n        minify: MinimizerPlugin.cleanCssMinify,\n        // Options - https://github.com/clean-css/clean-css#constructor-options\n        minimizerOptions: {},\n      }),\n    ],\n  },\n};\n```\n\n#### `esbuild`\n\n[`esbuild`](https://github.com/evanw/esbuild) ships with a fast CSS minifier (used via its CSS loader).\n\n**webpack.config.js**\n\n```js\nconst MinimizerPlugin = require(\"minimizer-webpack-plugin\");\n\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      \"...\",\n      new MinimizerPlugin({\n        test: /\\.css(\\?.*)?$/i,\n        minify: MinimizerPlugin.esbuildMinifyCss,\n        // Options - https://esbuild.github.io/api/#transform-api\n        minimizerOptions: {},\n      }),\n    ],\n  },\n};\n```\n\n#### `lightningcss`\n\n[`lightningcss`](https://github.com/parcel-bundler/lightningcss) is a Rust-based CSS parser, transformer, and minifier.\n\n**webpack.config.js**\n\n```js\nconst MinimizerPlugin = require(\"minimizer-webpack-plugin\");\n\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      \"...\",\n      new MinimizerPlugin({\n        test: /\\.css(\\?.*)?$/i,\n        minify: MinimizerPlugin.lightningCssMinify,\n        // Options - https://lightningcss.dev/transpilation.html\n        minimizerOptions: {},\n      }),\n    ],\n  },\n};\n```\n\n#### `@swc/css`\n\n[`@swc/css`](https://github.com/swc-project/swc) is a Rust-based CSS minifier.\n\n**webpack.config.js**\n\n```js\nconst MinimizerPlugin = require(\"minimizer-webpack-plugin\");\n\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      \"...\",\n      new MinimizerPlugin({\n        test: /\\.css(\\?.*)?$/i,\n        minify: MinimizerPlugin.swcMinifyCss,\n        // Options - https://github.com/swc-project/bindings/blob/main/packages/css/index.ts\n        minimizerOptions: {},\n      }),\n    ],\n  },\n};\n```\n\n### Custom Minify Function\n\nOverride the default minify function - use `uglify-js` for minification.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        minify: (file, sourceMap) =\u003e {\n          // https://github.com/mishoo/UglifyJS2#minify-options\n          const uglifyJsOptions = {\n            /* your `uglify-js` package options */\n          };\n\n          if (sourceMap) {\n            uglifyJsOptions.sourceMap = {\n              content: sourceMap,\n            };\n          }\n\n          return require(\"uglify-js\").minify(file, uglifyJsOptions);\n        },\n      }),\n    ],\n  },\n};\n```\n\n### Typescript\n\nWith default Terser minify function:\n\n```ts\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin({\n        minimizerOptions: {\n          compress: true,\n        },\n      }),\n    ],\n  },\n};\n```\n\nWith built-in minify functions:\n\n```ts\nimport { type JsMinifyOptions as SwcOptions } from \"@swc/core\";\nimport { type MinifyOptions as SwcCssOptions } from \"@swc/css\";\nimport {\n  type FragmentOptions as SwcHtmlFragmentOptions,\n  type Options as SwcHtmlOptions,\n} from \"@swc/html\";\nimport { type OptionsOutput as CleanCssOptions } from \"clean-css\";\nimport { type Options as CssnanoOptions } from \"cssnano\";\nimport { type CompressOptions as CssoOptions } from \"csso\";\nimport { type TransformOptions as EsbuildOptions } from \"esbuild\";\nimport { type Options as HtmlMinifierTerserOptions } from \"html-minifier-terser\";\nimport { type TransformOptions as LightningCssOptions } from \"lightningcss\";\nimport { type MinifyOptions as TerserOptions } from \"terser\";\nimport { type MinifyOptions as UglifyJSOptions } from \"uglify-js\";\n\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new MinimizerPlugin\u003cSwcOptions\u003e({\n        minify: MinimizerPlugin.swcMinify,\n        minimizerOptions: {\n          // `swc` options\n        },\n      }),\n      new MinimizerPlugin\u003cUglifyJSOptions\u003e({\n        minify: MinimizerPlugin.uglifyJsMinify,\n        minimizerOptions: {\n          // `uglif-js` options\n        },\n      }),\n      new MinimizerPlugin\u003cEsbuildOptions\u003e({\n        minify: MinimizerPlugin.esbuildMinify,\n        minimizerOptions: {\n          // `esbuild` options\n        },\n      }),\n\n      // Alternative usage:\n      new MinimizerPlugin\u003cTerserOptions\u003e({\n        minify: MinimizerPlugin.terserMinify,\n        minimizerOptions: {\n          // `terser` options\n        },\n      }),\n\n      // HTML minimizers\n      new MinimizerPlugin\u003cHtmlMinifierTerserOptions\u003e({\n        test: /\\.html(\\?.*)?$/i,\n        minify: MinimizerPlugin.htmlMinifierTerser,\n        minimizerOptions: {\n          // `html-minifier-terser` options\n        },\n      }),\n      new MinimizerPlugin\u003cSwcHtmlOptions\u003e({\n        test: /\\.html(\\?.*)?$/i,\n        minify: MinimizerPlugin.swcMinifyHtml,\n        minimizerOptions: {\n          // `@swc/html` options\n        },\n      }),\n      new MinimizerPlugin\u003cSwcHtmlFragmentOptions\u003e({\n        test: /\\.template\\.html$/i,\n        minify: MinimizerPlugin.swcMinifyHtmlFragment,\n        minimizerOptions: {\n          // `@swc/html` fragment options\n        },\n      }),\n\n      // CSS minimizers\n      new MinimizerPlugin\u003cCssnanoOptions\u003e({\n        test: /\\.css(\\?.*)?$/i,\n        minify: MinimizerPlugin.cssnanoMinify,\n        minimizerOptions: {\n          // `cssnano` options\n        },\n      }),\n      new MinimizerPlugin\u003cCssoOptions\u003e({\n        test: /\\.css(\\?.*)?$/i,\n        minify: MinimizerPlugin.cssoMinify,\n        minimizerOptions: {\n          // `csso` options\n        },\n      }),\n      new MinimizerPlugin\u003cCleanCssOptions\u003e({\n        test: /\\.css(\\?.*)?$/i,\n        minify: MinimizerPlugin.cleanCssMinify,\n        minimizerOptions: {\n          // `clean-css` options\n        },\n      }),\n      new MinimizerPlugin\u003cEsbuildOptions\u003e({\n        test: /\\.css(\\?.*)?$/i,\n        minify: MinimizerPlugin.esbuildMinifyCss,\n        minimizerOptions: {\n          // `esbuild` options (CSS loader)\n        },\n      }),\n      new MinimizerPlugin\u003cLightningCssOptions\u003e({\n        test: /\\.css(\\?.*)?$/i,\n        minify: MinimizerPlugin.lightningCssMinify,\n        minimizerOptions: {\n          // `lightningcss` options\n        },\n      }),\n      new MinimizerPlugin\u003cSwcCssOptions\u003e({\n        test: /\\.css(\\?.*)?$/i,\n        minify: MinimizerPlugin.swcMinifyCss,\n        minimizerOptions: {\n          // `@swc/css` options\n        },\n      }),\n    ],\n  },\n};\n```\n\n## Contributing\n\nWe welcome all contributions!\nIf you're new here, please take a moment to review our contributing guidelines before submitting issues or pull requests.\n\n[CONTRIBUTING](https://github.com/webpack/minimizer-webpack-plugin?tab=contributing-ov-file#contributing)\n\n## License\n\n[MIT](./LICENSE)\n\n[npm]: https://img.shields.io/npm/v/minimizer-webpack-plugin.svg\n[npm-url]: https://npmjs.com/package/minimizer-webpack-plugin\n[node]: https://img.shields.io/node/v/minimizer-webpack-plugin.svg\n[node-url]: https://nodejs.org\n[tests]: https://github.com/webpack/minimizer-webpack-plugin/workflows/minimizer-webpack-plugin/badge.svg\n[tests-url]: https://github.com/webpack/minimizer-webpack-plugin/actions\n[cover]: https://codecov.io/gh/webpack/minimizer-webpack-plugin/branch/main/graph/badge.svg\n[cover-url]: https://codecov.io/gh/webpack/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=minimizer-webpack-plugin\n[size-url]: https://packagephobia.now.sh/result?p=minimizer-webpack-plugin\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack%2Fminimizer-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebpack%2Fminimizer-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack%2Fminimizer-webpack-plugin/lists"}