{"id":32490058,"url":"https://github.com/webpack/compression-webpack-plugin","last_synced_at":"2025-10-27T08:19:53.722Z","repository":{"id":9890460,"uuid":"11895397","full_name":"webpack/compression-webpack-plugin","owner":"webpack","description":"Prepare compressed versions of assets to serve them with Content-Encoding","archived":false,"fork":false,"pushed_at":"2025-10-24T15:08:44.000Z","size":3448,"stargazers_count":1429,"open_issues_count":4,"forks_count":109,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-10-24T17:19:21.191Z","etag":null,"topics":["webpack-plugin"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"dennishucd/FFmpeg4Android","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webpack.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"open_collective":"webpack"}},"created_at":"2013-08-05T10:07:57.000Z","updated_at":"2025-10-24T15:08:46.000Z","dependencies_parsed_at":"2024-05-02T17:41:03.998Z","dependency_job_id":"c49d2995-0ef6-4bc1-927d-1410b36b898e","html_url":"https://github.com/webpack/compression-webpack-plugin","commit_stats":{"total_commits":272,"total_committers":39,"mean_commits":"6.9743589743589745","dds":0.7647058823529411,"last_synced_commit":"bcfd402d1655425e03443231f5ca9ff4fc100ce7"},"previous_names":["webpack/compression-webpack-plugin"],"tags_count":55,"template":false,"template_full_name":null,"purl":"pkg:github/webpack/compression-webpack-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fcompression-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fcompression-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fcompression-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fcompression-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webpack","download_url":"https://codeload.github.com/webpack/compression-webpack-plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fcompression-webpack-plugin/sbom","scorecard":{"id":1239163,"data":{"date":"2025-10-13","repo":{"name":"github.com/webpack/compression-webpack-plugin","commit":"f42651fabc6a89f89fb7e33262f3f6fddb23d2e3"},"scorecard":{"version":"v5.3.1-0.20251012233417-af419a5f4ac8","commit":"af419a5f4ac865788a844e5a2e726681cf4ff42b"},"score":5.9,"checks":[{"name":"Maintained","score":1,"reason":"2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/af419a5f4ac865788a844e5a2e726681cf4ff42b/docs/checks.md#maintained"}},{"name":"Code-Review","score":7,"reason":"Found 20/28 approved changesets -- score normalized to 7","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/af419a5f4ac865788a844e5a2e726681cf4ff42b/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/af419a5f4ac865788a844e5a2e726681cf4ff42b/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":10,"reason":"GitHub workflow tokens follow principle of least privilege","details":["Info: topLevel 'contents' permission set to 'read': .github/workflows/dependency-review.yml:5","Info: topLevel 'contents' permission set to 'read': .github/workflows/nodejs.yml:14","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/af419a5f4ac865788a844e5a2e726681cf4ff42b/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/af419a5f4ac865788a844e5a2e726681cf4ff42b/docs/checks.md#cii-best-practices"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/af419a5f4ac865788a844e5a2e726681cf4ff42b/docs/checks.md#packaging"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/af419a5f4ac865788a844e5a2e726681cf4ff42b/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/af419a5f4ac865788a844e5a2e726681cf4ff42b/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/af419a5f4ac865788a844e5a2e726681cf4ff42b/docs/checks.md#license"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/af419a5f4ac865788a844e5a2e726681cf4ff42b/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":4,"reason":"dependency not pinned by hash detected -- score normalized to 4","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/dependency-review.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/compression-webpack-plugin/dependency-review.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/dependency-review.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/compression-webpack-plugin/dependency-review.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/compression-webpack-plugin/nodejs.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/compression-webpack-plugin/nodejs.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:84: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/compression-webpack-plugin/nodejs.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:87: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/compression-webpack-plugin/nodejs.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs.yml:103: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/compression-webpack-plugin/nodejs.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/nodejs.yml:98","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   2 out of   3 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/af419a5f4ac865788a844e5a2e726681cf4ff42b/docs/checks.md#pinned-dependencies"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/af419a5f4ac865788a844e5a2e726681cf4ff42b/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: some github tokens can't read classic branch protection rules: https://github.com/ossf/scorecard-action/blob/main/docs/authentication/fine-grained-auth-token.md","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/af419a5f4ac865788a844e5a2e726681cf4ff42b/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 28 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/af419a5f4ac865788a844e5a2e726681cf4ff42b/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/af419a5f4ac865788a844e5a2e726681cf4ff42b/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-10-24T17:28:00.100Z","repository_id":9890460,"created_at":"2025-10-24T17:28:00.101Z","updated_at":"2025-10-24T17:28:00.101Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280906464,"owners_count":26411425,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-25T02:00:06.499Z","response_time":81,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["webpack-plugin"],"created_at":"2025-10-27T08:19:53.011Z","updated_at":"2025-10-27T08:19:53.714Z","avatar_url":"https://github.com/webpack.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/webpack/webpack\"\u003e\n    \u003cimg width=\"200\" height=\"200\" src=\"https://webpack.js.org/assets/icon-square-big.svg\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![tests][tests]][tests-url]\n[![cover][cover]][cover-url]\n[![discussion][discussion]][discussion-url]\n[![size][size]][size-url]\n\n# compression-webpack-plugin\n\nPrepare compressed versions of assets to serve them with Content-Encoding.\n\n## Getting Started\n\nTo begin, you'll need to install `compression-webpack-plugin`:\n\n```console\nnpm install compression-webpack-plugin --save-dev\n```\n\nor\n\n```console\nyarn add -D compression-webpack-plugin\n```\n\nor\n\n```console\npnpm add -D compression-webpack-plugin\n```\n\nThen add the plugin to your `webpack` config. For example:\n\n**webpack.config.js**\n\n```js\nconst CompressionPlugin = require(\"compression-webpack-plugin\");\n\nmodule.exports = {\n  plugins: [new CompressionPlugin()],\n};\n```\n\nFinally, run `webpack` using the method you normally use (e.g., via CLI or an npm script).\n\n## Options\n\n- **[`test`](#test)**\n- **[`include`](#include)**\n- **[`exclude`](#exclude)**\n- **[`algorithm`](#algorithm)**\n- **[`compressionOptions`](#compressionoptions)**\n- **[`threshold`](#threshold)**\n- **[`minRatio`](#minratio)**\n- **[`filename`](#filename)**\n- **[`deleteOriginalAssets`](#deleteoriginalassets)**\n\n### `test`\n\nType:\n\n```ts\ntype test = string | RegExp | (string | RegExp)[];\n```\n\nDefault: `undefined`\n\nInclude all assets that pass test assertion.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      test: /\\.js(\\?.*)?$/i,\n    }),\n  ],\n};\n```\n\n### `include`\n\nType:\n\n```ts\ntype include = string | RegExp | (string | RegExp)[];\n```\n\nDefault: `undefined`\n\nInclude all assets matching any of these conditions.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      include: /\\/includes/,\n    }),\n  ],\n};\n```\n\n### `exclude`\n\nType:\n\n```ts\ntype exclude = string | RegExp | (string | RegExp)[];\n```\n\nDefault: `undefined`\n\nExclude all assets matching any of these conditions.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      exclude: /\\/excludes/,\n    }),\n  ],\n};\n```\n\n### `algorithm`\n\nType:\n\n```ts\ntype algorithm =\n  | string\n  | ((\n      input: Buffer,\n      options: CompressionOptions,\n      callback: (\n        error: Error | null | undefined,\n        result:\n          | string\n          | ArrayBuffer\n          | SharedArrayBuffer\n          | Uint8Array\n          | readonly number[]\n          | {\n              valueOf(): ArrayBuffer | SharedArrayBuffer;\n            }\n          | {\n              valueOf(): string | Uint8Array | readonly number[];\n            }\n          | {\n              valueOf(): string;\n            }\n          | {\n              [Symbol.toPrimitive](hint: \"string\"): string;\n            },\n      ) =\u003e void,\n    ) =\u003e void);\n```\n\nDefines the compression algorithm or function to use. Defaults to `gzip`.\n\n\u003e [!NOTE]\n\u003e\n\u003e If you use a custom function for the `algorithm` option, the default value of `compressionOptions` will be an empty object `{}`.\n\n#### `string`\n\nThe algorithm is based on the Node.js [zlib](https://nodejs.org/api/zlib.html) module.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      algorithm: \"gzip\",\n    }),\n  ],\n};\n```\n\n#### `function`\n\nAllow you to specify a custom compression function.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      algorithm(input, compressionOptions, callback) {\n        return compressionFunction(input, compressionOptions, callback);\n      },\n    }),\n  ],\n};\n```\n\n### `compressionOptions`\n\nType:\n\n```ts\ninterface compressionOptions {\n  flush?: number;\n  finishFlush?: number;\n  chunkSize?: number;\n  windowBits?: number;\n  level?: number;\n  memLevel?: number;\n  strategy?: number;\n  dictionary?: Buffer | TypedArray | DataView | ArrayBuffer;\n  info?: boolean;\n  maxOutputLength?: number;\n}\n```\n\nDefault: `{ level: 9 }`\n\nCompression options for `algorithm`.\n\nYou can find all available options in the [zlib](https://nodejs.org/api/zlib.html#zlib_class_options) documentation.\n\n\u003e [!NOTE]\n\u003e\n\u003e If you use a custom function for the `algorithm` option, the default value of `compressionOptions` will be an empty object `{}`.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      compressionOptions: { level: 1 },\n    }),\n  ],\n};\n```\n\n### `threshold`\n\nType:\n\n```ts\ntype threshold = number;\n```\n\nDefault: `0`\n\nOnly assets larger than this size (in bytes) are processed.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      threshold: 8192,\n    }),\n  ],\n};\n```\n\n### `minRatio`\n\nType:\n\n```ts\ntype minRatio = number;\n```\n\nDefault: `0.8`\n\nOnly assets that compress better than this ratio are processed (`minRatio = Compressed Size / Original Size`).\nFor example, if you have a `image.png` file with a size of 1024 bytes, and its compressed version is of 768 bytes, the `minRatio` is `0.75`.\nIn other words, assets will be processed only when the ratio of `Compressed Size / Original Size` is less than the specified `minRatio`.\n\nYou can use a value of `1` to process assets that are smaller than or equal to the original size.\n\nUse a value of `Infinity` to process all assets, even if they are larger than the original size or their original size is `0` bytes (useful when you are pre-zipping all assets for AWS).\n\nUse a value of `Number.MAX_SAFE_INTEGER` to process all assets even if they are larger than the original size, excluding assets with their original size is `0` bytes.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      // Compress all assets, including files with `0` bytes size\n      // minRatio: Infinity\n\n      // Compress all assets, excluding files with `0` bytes size\n      // minRatio: Number.MAX_SAFE_INTEGER\n\n      minRatio: 0.8,\n    }),\n  ],\n};\n```\n\n### `filename`\n\nType:\n\n```ts\ntype filename = string | ((pathdata: PathData) =\u003e string);\n```\n\nDefault: `\"[path][base].gz\"`\n\nThe target asset filename.\n\n#### `string`\n\nFor example, given an asset path: `assets/images/image.png?foo=bar#hash`:\n\n`[path]` is replaced with the directories of the original asset, including the trailing `/` (`assets/images/`).\n\n`[file]` is replaced with the path of the original asset (`assets/images/image.png`).\n\n`[base]` is replaced with the base name (`[name]` + `[ext]`) of the original asset (`image.png`).\n\n`[name]` is replaced with the name of the original asset (`image`).\n\n`[ext]` is replaced with the extension of the original asset, including the `.` (`.png`).\n\n`[query]` is replaced with the query of the original asset, including the `?` (`?foo=bar`).\n\n`[fragment]` is replaced with the fragment (in the concept of URL it is called `hash`) of the original asset (`#hash`).\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      filename: \"[path][base].gz\",\n    }),\n  ],\n};\n```\n\n#### `function`\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      filename(pathData) {\n        // The `pathData` argument contains all placeholders - `path`/`name`/`ext`/etc\n        // Available properties described above, for the `String` notation\n        if (/\\.svg$/.test(pathData.filename)) {\n          return \"assets/svg/[path][base].gz\";\n        }\n\n        return \"assets/js/[path][base].gz\";\n      },\n    }),\n  ],\n};\n```\n\n### `deleteOriginalAssets`\n\nType:\n\n```ts\ntype deleteOriginalAssets =\n  | boolean\n  | \"keep-source-map\"\n  | ((name: string) =\u003e boolean);\n```\n\nDefault: `false`\n\nDetermines whether the original (uncompressed) assets should be deleted after compression.\n\n- If set to `true` , all original assets will be deleted.\n\n- If set to `\"keep-source-map\"`, all original assets except source maps (`.map` files) will be deleted.\n\n- If a function is provided, it will be called with each asset’s name and should return `true` to delete the asset or `false` to keep it.\n\nExample:\n\n```js\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      deleteOriginalAssets: (assetName) =\u003e\n        // Delete all assets except images\n        !assetName.endsWith(\".png\") \u0026\u0026 !assetName.endsWith(\".jpg\"),\n    }),\n  ],\n};\n```\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      deleteOriginalAssets: true,\n    }),\n  ],\n};\n```\n\nTo exclude sourcemaps from compression:\n\n```js\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      exclude: /.map$/,\n      deleteOriginalAssets: \"keep-source-map\",\n    }),\n  ],\n};\n```\n\nUsing a custom function:\n\n```js\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      exclude: /.map$/,\n      deleteOriginalAssets: (name) =\u003e {\n        if (/\\.js$/.test(name)) {\n          return false;\n        }\n\n        return true;\n      },\n    }),\n  ],\n};\n```\n\n## Examples\n\n### Using Zopfli\n\nPrepare compressed versions of assets using the `zopfli` library.\n\n\u003e [!NOTE]\n\u003e\n\u003e `@gfx/zopfli` requires at least `Node.js` version `8`.\n\nTo begin, you'll need to install `@gfx/zopfli`:\n\n```console\n$ npm install @gfx/zopfli --save-dev\n```\n\n**webpack.config.js**\n\n```js\nconst zopfli = require(\"@gfx/zopfli\");\n\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      compressionOptions: {\n        numiterations: 15,\n      },\n      algorithm(input, compressionOptions, callback) {\n        return zopfli.gzip(input, compressionOptions, callback);\n      },\n    }),\n  ],\n};\n```\n\n### Using Brotli\n\n[Brotli](https://en.wikipedia.org/wiki/Brotli) is a compression algorithm originally developed by Google, and offers compression superior to gzip.\n\nNode.js v10.16.0 and later includes [native support](https://nodejs.org/api/zlib.html#zlib_zlib_createbrotlicompress_options) for Brotli compression in its `zlib` module.\n\nYou can take advantage of this built-in support for Brotli in Node 10.16.0 and later by just passing in the appropriate `algorithm` to the CompressionPlugin:\n\n**webpack.config.js**\n\n```js\nconst zlib = require(\"node:zlib\");\n\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      filename: \"[path][base].br\",\n      algorithm: \"brotliCompress\",\n      test: /\\.(js|css|html|svg)$/,\n      compressionOptions: {\n        params: {\n          [zlib.constants.BROTLI_PARAM_QUALITY]: 11,\n        },\n      },\n      threshold: 10240,\n      minRatio: 0.8,\n      deleteOriginalAssets: false,\n    }),\n  ],\n};\n```\n\n[!NOTE] Brotli’s `BROTLI_PARAM_QUALITY` option is functionally equivalent to zlib’s `level` option.\nYou can find all Brotli’s options in [the relevant part of the zlib module documentation](https://nodejs.org/api/zlib.html#zlib_class_brotlioptions).\n\n### Using Zstandard\n\n[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.\n\nNode.js 22.15.0 and later includes [native support](https://nodejs.org/api/zlib.html#zlibcreatezstdcompressoptions) for Zstandard compression in its `zlib` module.\n\nYou 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:\n\n**webpack.config.js**\n\n```js\nconst zlib = require(\"node:zlib\");\n\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      filename: \"[path][base].zst\",\n      algorithm: \"zstdCompress\",\n      test: /\\.(js|css|html|svg)$/,\n      compressionOptions: {\n        params: {\n          [zlib.constants.ZSTD_c_compressionLevel]: 10,\n        },\n      },\n      threshold: 10240,\n      minRatio: 0.8,\n      deleteOriginalAssets: false,\n    }),\n  ],\n};\n```\n\nYou can find all Zstandard's options in [the relevant part of the zlib module documentation](https://nodejs.org/api/zlib.html#class-zstdoptions).\n\n### Multiple compressed versions of assets for different algorithm\n\n**webpack.config.js**\n\n```js\nconst zlib = require(\"node:zlib\");\n\nmodule.exports = {\n  plugins: [\n    new CompressionPlugin({\n      filename: \"[path][base].gz\",\n      algorithm: \"gzip\",\n      test: /\\.js$|\\.css$|\\.html$/,\n      threshold: 10240,\n      minRatio: 0.8,\n    }),\n    new CompressionPlugin({\n      filename: \"[path][base].br\",\n      algorithm: \"brotliCompress\",\n      test: /\\.(js|css|html|svg)$/,\n      compressionOptions: {\n        params: {\n          [zlib.constants.BROTLI_PARAM_QUALITY]: 11,\n        },\n      },\n      threshold: 10240,\n      minRatio: 0.8,\n    }),\n  ],\n};\n```\n\n## Contributing\n\nWe welcome contributions!\n\nPlease take a moment to read our contributing guidelines if you haven't yet done so.\n\n[CONTRIBUTING](./.github/CONTRIBUTING.md)\n\n## License\n\n[MIT](./LICENSE)\n\n[npm]: https://img.shields.io/npm/v/compression-webpack-plugin.svg\n[npm-url]: https://npmjs.com/package/compression-webpack-plugin\n[node]: https://img.shields.io/node/v/compression-webpack-plugin.svg\n[node-url]: https://nodejs.org\n[tests]: https://github.com/webpack/compression-webpack-plugin/workflows/compression-webpack-plugin/badge.svg\n[tests-url]: https://github.com/webpack/compression-webpack-plugin/actions\n[cover]: https://codecov.io/gh/webpack/compression-webpack-plugin/branch/main/graph/badge.svg\n[cover-url]: https://codecov.io/gh/webpack/compression-webpack-plugin\n[discussion]: https://img.shields.io/github/discussions/webpack/webpack\n[discussion-url]: https://github.com/webpack/webpack/discussions\n[size]: https://packagephobia.now.sh/badge?p=compression-webpack-plugin\n[size-url]: https://packagephobia.now.sh/result?p=compression-webpack-plugin\n","funding_links":["https://opencollective.com/webpack"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack%2Fcompression-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebpack%2Fcompression-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack%2Fcompression-webpack-plugin/lists"}