From 42bf6edcc036725c5ec686e360e8f70e84fe1f4d Mon Sep 17 00:00:00 2001 From: James Ross Date: Fri, 13 Jun 2025 16:40:44 +0100 Subject: [PATCH 1/3] docs: add zstd information --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index cf5600d..0af8f77 100644 --- a/README.md +++ b/README.md @@ -524,6 +524,41 @@ module.exports = { [!NOTE] Brotli’s `BROTLI_PARAM_QUALITY` option is functionally equivalent to zlib’s `level` option. 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). +### Using Zstandard + +[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. + +Node.js 22.15.0 and later includes [native support](https://nodejs.org/api/zlib.html#zlibcreatezstdcompressoptions) for Zstandard compression in its `zlib` module. + +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: + +**webpack.config.js** + +```js +const zlib = require("zlib"); + +module.exports = { + plugins: [ + new CompressionPlugin({ + filename: "[path][base].zst", + algorithm: "zstdCompress", + test: /\.(js|css|html|svg)$/, + compressionOptions: { + params: { + [zlib.constants.ZSTD_c_compressionLevel]: 10, + }, + }, + threshold: 10240, + minRatio: 0.8, + deleteOriginalAssets: false, + }), + ], +}; +``` + +You can find all Zstandard's options in [the relevant part of the zlib module documentation](https://nodejs.org/api/zlib.html#class-zstdoptions). + + ### Multiple compressed versions of assets for different algorithm **webpack.config.js** From ddd39b36c076561b84c9bbc7ca0aeaf935c8155c Mon Sep 17 00:00:00 2001 From: James Ross Date: Fri, 20 Jun 2025 18:58:29 +0100 Subject: [PATCH 2/3] chore: prettier --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 0af8f77..7fdbfb4 100644 --- a/README.md +++ b/README.md @@ -558,7 +558,6 @@ module.exports = { You can find all Zstandard's options in [the relevant part of the zlib module documentation](https://nodejs.org/api/zlib.html#class-zstdoptions). - ### Multiple compressed versions of assets for different algorithm **webpack.config.js** From de07189214677fab4503b1ad2db09104b84291f8 Mon Sep 17 00:00:00 2001 From: James Ross Date: Mon, 23 Jun 2025 13:35:20 +0100 Subject: [PATCH 3/3] chore: spelling lint --- .cspell.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.cspell.json b/.cspell.json index da2fbf3..520b944 100644 --- a/.cspell.json +++ b/.cspell.json @@ -13,6 +13,9 @@ "Brotli’s", "BROTLI", "brotli", + "Zstandard", + "Zstandard’s", + "zstd", "Koppers", "sokra", "precache",