Skip to content

Commit 055d50d

Browse files
docs: multiple compressed versions of assets for different algorithm
1 parent b7e65f2 commit 055d50d

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,9 @@ Node 11.7.0 and later has [native support](https://nodejs.org/api/zlib.html#zlib
284284

285285
We can take advantage of this built-in support for Brotli in Node 11.7.0 and later by just passing in the appropriate `algorithm` to the CompressionPlugin:
286286

287+
**webpack.config.js**
288+
287289
```js
288-
// in your webpack.config.js
289290
module.exports = {
290291
plugins: [
291292
new CompressionPlugin({
@@ -303,6 +304,32 @@ module.exports = {
303304

304305
**N.B.:** The `level` option matches `BROTLI_PARAM_QUALITY` [for Brotli-based streams](https://nodejs.org/api/zlib.html#zlib_for_brotli_based_streams)
305306

307+
### Multiple compressed versions of assets for different algorithm
308+
309+
**webpack.config.js**
310+
311+
```js
312+
module.exports = {
313+
plugins: [
314+
new CompressionPlugin({
315+
filename: '[path].gz[query]',
316+
algorithm: 'gzip',
317+
test: /\.js$|\.css$|\.html$/,
318+
threshold: 10240,
319+
minRatio: 0.8,
320+
}),
321+
new CompressionPlugin({
322+
filename: '[path].br[query]',
323+
algorithm: 'brotliCompress',
324+
test: /\.(js|css|html|svg)$/,
325+
compressionOptions: { level: 11 },
326+
threshold: 10240,
327+
minRatio: 0.8,
328+
}),
329+
],
330+
};
331+
```
332+
306333
## Contributing
307334

308335
Please take a moment to read our contributing guidelines if you haven't yet done so.

0 commit comments

Comments
 (0)