You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+251-2Lines changed: 251 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,8 +14,9 @@
14
14
# terser-webpack-plugin
15
15
16
16
This plugin minifies your assets in a webpack build. It ships with several
17
-
built-in minimizers covering JavaScript, JSON, and HTML — pick one with the
18
-
[`minify`](#minify) option and target the right files with [`test`](#test).
17
+
built-in minimizers covering JavaScript, JSON, HTML, and CSS — pick one
18
+
with the [`minify`](#minify) option and target the right files with
19
+
[`test`](#test).
19
20
20
21
JavaScript minimizers:
21
22
@@ -34,6 +35,15 @@ HTML minimizers:
34
35
-[`@swc/html`](https://github.com/swc-project/swc) — `TerserPlugin.swcMinifyHtml` (full HTML documents) and `TerserPlugin.swcMinifyHtmlFragment` (HTML fragments, e.g. `<template>` content). Very fast Rust-based platform for the Web. Requires `npm install --save-dev @swc/html`.
35
36
-[`@minify-html/node`](https://github.com/wilsonzlin/minify-html) — `TerserPlugin.minifyHtmlNode`. A Rust HTML minifier optimised for speed and effectiveness. Requires `npm install --save-dev @minify-html/node`.
36
37
38
+
CSS minimizers:
39
+
40
+
-[`cssnano`](https://cssnano.github.io/cssnano/) — `TerserPlugin.cssnanoMinify`. The default CSS minimizer. Built on top of [PostCSS](https://postcss.org/). Requires `npm install --save-dev cssnano postcss`.
41
+
-[`csso`](https://github.com/css/csso) — `TerserPlugin.cssoMinify`. A CSS minifier with structural optimisations. Requires `npm install --save-dev csso`.
-[`esbuild`](https://github.com/evanw/esbuild) — `TerserPlugin.esbuildMinifyCss`. Very fast CSS minification using esbuild's CSS loader. Requires `npm install --save-dev esbuild`.
44
+
-[`lightningcss`](https://github.com/parcel-bundler/lightningcss) — `TerserPlugin.lightningCssMinify`. A Rust-based CSS parser, transformer, and minifier. Requires `npm install --save-dev lightningcss`.
45
+
-[`@swc/css`](https://github.com/swc-project/swc) — `TerserPlugin.swcMinifyCss`. A very fast Rust-based CSS minifier. Requires `npm install --save-dev @swc/css`.
46
+
37
47
All of the non-default minimizers are declared as **optional** peer
38
48
dependencies — install only the ones you actually use. You can also stack
39
49
multiple `TerserPlugin` instances in the same build to handle different
@@ -1065,6 +1075,196 @@ module.exports = {
1065
1075
1066
1076
You can also stack multiple `TerserPlugin` instances to compress different files with different `minify` functions in the same build (e.g. JS with `terserMinify`, HTML with `htmlMinifierTerser`, JSON with `jsonMinify`).
1067
1077
1078
+
### CSS
1079
+
1080
+
The plugin can minify CSS assets too. Pick one of the bundled CSS
1081
+
minimizers and set `test` to match your CSS files.
0 commit comments