Gathering detailed insights and metrics for @theia/compression-webpack-plugin
Gathering detailed insights and metrics for @theia/compression-webpack-plugin
Gathering detailed insights and metrics for @theia/compression-webpack-plugin
Gathering detailed insights and metrics for @theia/compression-webpack-plugin
Prepare compressed versions of assets to serve them with Content-Encoding
npm install @theia/compression-webpack-plugin
Typescript
Module System
Min. Node Version
Node Version
NPM Version
38.3
Supply Chain
52.1
Quality
74.1
Maintenance
50
Vulnerability
96.7
License
JavaScript (100%)
Total Downloads
589,730
Last Day
2
Last Week
127
Last Month
452
Last Year
9,699
MIT License
1,428 Stars
280 Commits
109 Forks
24 Watchers
5 Branches
48 Contributors
Updated on Jun 25, 2025
Minified
Minified + Gzipped
Latest Version
3.0.0
Package Id
@theia/compression-webpack-plugin@3.0.0
Size
8.07 kB
NPM Version
6.4.1
Node Version
10.15.3
Published on
Oct 15, 2019
Cumulative downloads
Total Downloads
Last Day
-80%
2
Compared to previous day
Last Week
22.1%
127
Compared to previous week
Last Month
-12.9%
452
Compared to previous month
Last Year
-48.3%
9,699
Compared to previous year
1
26
Prepare compressed versions of assets to serve them with Content-Encoding.
This module requires a minimum of Node v6.9.0 and Webpack v4.0.0.
To begin, you'll need to install compression-webpack-plugin
:
1$ npm install compression-webpack-plugin --save-dev
Then add the plugin to your webpack
config. For example:
webpack.config.js
1const CompressionPlugin = require('compression-webpack-plugin'); 2 3module.exports = { 4 plugins: [new CompressionPlugin()], 5};
And run webpack
via your preferred method.
test
Type: String|RegExp|Array<String|RegExp>
Default: undefined
Test to match files against.
1// in your webpack.config.js
2new CompressionPlugin({
3 test: /\.js(\?.*)?$/i,
4});
include
Type: String|RegExp|Array<String|RegExp>
Default: undefined
Files to include.
1// in your webpack.config.js 2new CompressionPlugin({ 3 include: /\/includes/, 4});
exclude
Type: String|RegExp|Array<String|RegExp>
Default: undefined
Files to exclude.
1// in your webpack.config.js 2new CompressionPlugin({ 3 exclude: /\/excludes/, 4});
cache
Type: Boolean|String
Default: false
Enable file caching.
The default path to cache directory: node_modules/.cache/compression-webpack-plugin
.
Boolean
Enable/disable file caching.
1// in your webpack.config.js
2new CompressionPlugin({
3 cache: true,
4});
String
Enable file caching and set path to cache directory.
1// in your webpack.config.js
2new CompressionPlugin({
3 cache: 'path/to/cache',
4});
filename
Type: String|Function
Default: [path].gz[query]
The target asset filename.
String
[file]
is replaced with the original asset filename.
[path]
is replaced with the path of the original asset.
[query]
is replaced with the query.
1// in your webpack.config.js 2new CompressionPlugin({ 3 filename: '[path].gz[query]', 4});
Function
1// in your webpack.config.js 2new CompressionPlugin({ 3 filename(info) { 4 // info.file is the original asset filename 5 // info.path is the path of the original asset 6 // info.query is the query 7 return `${info.path}.gz${info.query}`; 8 }, 9});
algorithm
Type: String|Function
Default: gzip
The compression algorithm/function.
String
The algorithm is taken from zlib.
1// in your webpack.config.js
2new CompressionPlugin({
3 algorithm: 'gzip',
4});
Function
Allow to specify a custom compression function.
1// in your webpack.config.js
2new CompressionPlugin({
3 algorithm(input, compressionOptions, callback) {
4 return compressionFunction(input, compressionOptions, callback);
5 },
6});
compressionOptions
Type: Object
Default: { level: 9 }
If you use custom function for the algorithm
option, the default value is {}
.
Compression options. You can find all options here zlib.
1// in your webpack.config.js 2new CompressionPlugin({ 3 compressionOptions: { level: 1 }, 4});
threshold
Type: Number
Default: 0
Only assets bigger than this size are processed. In bytes.
1// in your webpack.config.js
2new CompressionPlugin({
3 threshold: 8192,
4});
minRatio
Type: Number
Default: 0.8
Only assets that compress better than this ratio are processed (minRatio = Compressed Size / Original Size
).
Example: you have image.png
file with 1024b size, compressed version of file has 768b size, so minRatio
equal 0.75
.
In other words assets will be processed when the Compressed Size / Original Size
value less minRatio
value.
You can use 1
value to process all assets.
1// in your webpack.config.js
2new CompressionPlugin({
3 minRatio: 0.8,
4});
deleteOriginalAssets
Type: Boolean
Default: false
Whether to delete the original assets or not.
1// in your webpack.config.js
2new CompressionPlugin({
3 deleteOriginalAssets: true,
4});
Prepare compressed versions of assets using zopfli
library.
ℹ️
@gfx/zopfli
require minimum8
version ofnode
.
To begin, you'll need to install @gfx/zopfli
:
1$ npm install @gfx/zopfli --save-dev
webpack.config.js
1const zopfli = require('@gfx/zopfli'); 2 3module.exports = { 4 plugins: [ 5 new CompressionPlugin({ 6 compressionOptions: { 7 numiterations: 15, 8 }, 9 algorithm(input, compressionOptions, callback) { 10 return zopfli.gzip(input, compressionOptions, callback); 11 }, 12 }), 13 ], 14};
Brotli is a compression algorithm originally developed by Google, and offers compression superior to gzip.
Node 11.7.0 and later has native support for Brotli compression in its zlib module.
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:
1// in your webpack.config.js 2module.exports = { 3 plugins: [ 4 new CompressionPlugin({ 5 filename: '[path].br[query]', 6 algorithm: 'brotliCompress', 7 test: /\.(js|css|html|svg)$/, 8 compressionOptions: { level: 11 }, 9 threshold: 10240, 10 minRatio: 0.8, 11 deleteOriginalAssets: false, 12 }), 13 ], 14};
N.B.: The level
option matches BROTLI_PARAM_QUALITY
for Brotli-based streams
Please take a moment to read our contributing guidelines if you haven't yet done so.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 21/28 approved changesets -- score normalized to 7
Reason
6 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 5
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More