Skip to content

Commit 42bf6ed

Browse files
committed
docs: add zstd information
1 parent 10a7bdc commit 42bf6ed

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,41 @@ module.exports = {
524524
[!NOTE] Brotli’s `BROTLI_PARAM_QUALITY` option is functionally equivalent to zlib’s `level` option.
525525
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).
526526

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+
const zlib = require("zlib");
539+
540+
module.exports = {
541+
plugins: [
542+
new CompressionPlugin({
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+
561+
527562
### Multiple compressed versions of assets for different algorithm
528563

529564
**webpack.config.js**

0 commit comments

Comments
 (0)