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
+34Lines changed: 34 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -524,6 +524,40 @@ module.exports = {
524
524
[!NOTE] Brotli’s `BROTLI_PARAM_QUALITY` option is functionally equivalent to zlib’s `level` option.
525
525
You can find all Brotli’s options in [the relevant part of the zlib module documentation](https://nodejs.org/api/zlib.html#zlib_class_brotlioptions).
526
526
527
+
### Using Zstandard
528
+
529
+
[Zstandard](https://facebook.github.io/zstd/) (zstd) is a fast lossless compression algorithm, targeting real-time compression scenarios at zlib-level and better compression ratios.
530
+
531
+
Node.js 22.15.0 and later includes [native support](https://nodejs.org/api/zlib.html#zlibcreatezstdcompressoptions) for Zstandard compression in its `zlib` module.
532
+
533
+
You can take advantage of this built-in support for zstd in Node 22.15.0 and later by just passing in the appropriate `algorithm` to the CompressionPlugin:
534
+
535
+
**webpack.config.js**
536
+
537
+
```js
538
+
constzlib=require("zlib");
539
+
540
+
module.exports= {
541
+
plugins: [
542
+
newCompressionPlugin({
543
+
filename:"[path][base].zst",
544
+
algorithm:"zstdCompress",
545
+
test:/\.(js|css|html|svg)$/,
546
+
compressionOptions: {
547
+
params: {
548
+
[zlib.constants.ZSTD_c_compressionLevel]:10,
549
+
},
550
+
},
551
+
threshold:10240,
552
+
minRatio:0.8,
553
+
deleteOriginalAssets:false,
554
+
}),
555
+
],
556
+
};
557
+
```
558
+
559
+
You can find all Zstandard's options in [the relevant part of the zlib module documentation](https://nodejs.org/api/zlib.html#class-zstdoptions).
560
+
527
561
### Multiple compressed versions of assets for different algorithm
0 commit comments