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
+27Lines changed: 27 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -278,6 +278,33 @@ module.exports = {
278
278
}
279
279
```
280
280
281
+
### Using Brotli
282
+
283
+
[Brotli](https://en.wikipedia.org/wiki/Brotli) is a compression algorithm originally developed by Google, and offers compression superior to gzip.
284
+
285
+
Node 11.7.0 and later has [native support](https://nodejs.org/api/zlib.html#zlib_zlib_createbrotlicompress_options) for Brotli compression in its zlib module.
286
+
287
+
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:
288
+
289
+
```js
290
+
// in your webpack.config.js
291
+
module.exports= {
292
+
plugins: [
293
+
newCompressionPlugin({
294
+
filename:'[path].br[query]',
295
+
algorithm:'brotliCompress',
296
+
test:/\.(js|css|html|svg)$/,
297
+
compressionOptions: { level:11 },
298
+
threshold:10240,
299
+
minRatio:0.8,
300
+
deleteOriginalAssets:false
301
+
})
302
+
]
303
+
}
304
+
```
305
+
306
+
**N.B.:** The `level` option matches `BROTLI_PARAM_QUALITY`[for Brotli-based streams](https://nodejs.org/api/zlib.html#zlib_for_brotli_based_streams)
307
+
281
308
## Contributing
282
309
283
310
Please take a moment to read our contributing guidelines if you haven't yet done so.
0 commit comments