From 65e4b786ea98a911dd79910cf3b9178b9410795f Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 4 May 2026 18:21:28 +0000 Subject: [PATCH 01/18] feat: add built-in CSS minimizers from css-minimizer-webpack-plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the CSS minifier implementations from `css-minimizer-webpack-plugin` into this plugin so CSS assets can be minified via the standard `TerserPlugin` interface. Adds six new static helpers: - `TerserPlugin.cssnanoMinify` (uses `cssnano` + `postcss`) - `TerserPlugin.cssoMinify` (uses `csso`) - `TerserPlugin.cleanCssMinify` (uses `clean-css`) - `TerserPlugin.esbuildMinifyCss` (uses `esbuild` with the CSS loader) - `TerserPlugin.lightningCssMinify` (uses `lightningcss`) - `TerserPlugin.swcMinifyCss` (uses `@swc/css`) The CSS packages are declared as optional peer dependencies — install only the one you actually use. Documentation in the README now includes a dedicated CSS section with usage examples for each minimizer. --- .cspell.json | 8 +- README.md | 253 ++- package-lock.json | 1684 +++++++++++++++-- package.json | 33 +- src/index.js | 12 + src/utils.js | 545 ++++++ test/__snapshots__/minify-option.test.js.snap | 118 ++ test/fixtures/css.js | 1 + test/fixtures/file.css | 11 + test/minify-option.test.js | 193 ++ types/index.d.ts | 12 + types/utils.d.ts | 132 ++ 12 files changed, 2870 insertions(+), 132 deletions(-) create mode 100644 test/fixtures/css.js create mode 100644 test/fixtures/file.css diff --git a/.cspell.json b/.cspell.json index e0199bbc..74ad4e55 100644 --- a/.cspell.json +++ b/.cspell.json @@ -40,7 +40,13 @@ "nocheck", "dont", "doctype", - "wilsonzlin" + "wilsonzlin", + "cssnano", + "csso", + "lightningcss", + "sourcefile", + "stringifier", + "sourcesContent" ], "ignorePaths": [ "CHANGELOG.md", diff --git a/README.md b/README.md index 481e94df..1265c254 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,9 @@ # terser-webpack-plugin This plugin minifies your assets in a webpack build. It ships with several -built-in minimizers covering JavaScript, JSON, and HTML — pick one with the -[`minify`](#minify) option and target the right files with [`test`](#test). +built-in minimizers covering JavaScript, JSON, HTML, and CSS — pick one +with the [`minify`](#minify) option and target the right files with +[`test`](#test). JavaScript minimizers: @@ -34,6 +35,15 @@ HTML minimizers: - [`@swc/html`](https://github.com/swc-project/swc) — `TerserPlugin.swcMinifyHtml` (full HTML documents) and `TerserPlugin.swcMinifyHtmlFragment` (HTML fragments, e.g. `