@@ -996,6 +996,46 @@ what `stage` states rather than what applying two plugins in the right order
996996happens to give. Each algorithm is run at its own maximum by default (` zlib` 's
997997best level, brotli's best quality); name ` compressionOptions` to say otherwise.
998998
999+ #### Compressing with minifying, and without
1000+
1001+ The example above does both: ` minify` defaults to terser, so the bundle is
1002+ minified and the compressed files are written from what minification produced.
1003+ That is the shape to want — one pass of filtering, one cache, and ` stage`
1004+ ordering the two — and it needs nothing said about ` minify` at all:
1005+
1006+ ` ` ` js
1007+ new MinimizerPlugin ({
1008+ test: / \. (js| css| html| svg)$ / i ,
1009+ generate: {
1010+ implementation: MinimizerPlugin .compress ,
1011+ options: { algorithm: " gzip" },
1012+ type: " asset" ,
1013+ filename: " [path][base].gz" ,
1014+ },
1015+ });
1016+ ` ` `
1017+
1018+ Compressing **only** — an instance that must not touch what it reads — says so
1019+ with an empty list of minimizers. ` test` is then yours to state too, since the
1020+ ` .js ` default belongs to minifying:
1021+
1022+ ` ` ` js
1023+ new MinimizerPlugin ({
1024+ test: / . * / ,
1025+ minify: [],
1026+ generate: {
1027+ implementation: MinimizerPlugin .compress ,
1028+ options: { algorithm: " gzip" },
1029+ type: " asset" ,
1030+ filename: " [path][base].gz" ,
1031+ },
1032+ });
1033+ ` ` `
1034+
1035+ Nothing is minified, no asset is marked ` minimized` , and the bundle keeps the
1036+ name it would have had without this plugin — an instance that rewrites nothing
1037+ salts no hash.
1038+
9991039It is an ordinary minimizer too, so [` minify` ](#minify) takes it the way it
10001040takes ` terserMinify` or ` swcMinify` . There it compresses the asset **in place**
10011041rather than beside it — the shape for a server that says what the encoding is
0 commit comments