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
+28-1Lines changed: 28 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -284,8 +284,9 @@ Node 11.7.0 and later has [native support](https://nodejs.org/api/zlib.html#zlib
284
284
285
285
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:
286
286
287
+
**webpack.config.js**
288
+
287
289
```js
288
-
// in your webpack.config.js
289
290
module.exports= {
290
291
plugins: [
291
292
newCompressionPlugin({
@@ -303,6 +304,32 @@ module.exports = {
303
304
304
305
**N.B.:** The `level` option matches `BROTLI_PARAM_QUALITY`[for Brotli-based streams](https://nodejs.org/api/zlib.html#zlib_for_brotli_based_streams)
305
306
307
+
### Multiple compressed versions of assets for different algorithm
308
+
309
+
**webpack.config.js**
310
+
311
+
```js
312
+
module.exports= {
313
+
plugins: [
314
+
newCompressionPlugin({
315
+
filename:'[path].gz[query]',
316
+
algorithm:'gzip',
317
+
test:/\.js$|\.css$|\.html$/,
318
+
threshold:10240,
319
+
minRatio:0.8,
320
+
}),
321
+
newCompressionPlugin({
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
+
306
333
## Contributing
307
334
308
335
Please take a moment to read our contributing guidelines if you haven't yet done so.
0 commit comments