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
|**[`test`](#test)**|`{String\|RegExp\|Array<String\|RegExp>}`|`undefined`| Include all assets that pass test assertion |
46
+
|**[`include`](#include)**|`{String\|RegExp\|Array<String\|RegExp>}`|`undefined`| Include all assets matching any of these conditions |
47
+
|**[`exclude`](#exclude)**|`{String\|RegExp\|Array<String\|RegExp>}`|`undefined`| Exclude all assets matching any of these conditions |
48
+
|**[`algorithm`](#algorithm)**|`{String\|Function}`|`gzip`| The compression algorithm/function |
49
+
|**[`compressionOptions`](#compressionoptions)**|`{Object}`|`{ level: 9 }`| Compression options for `algorithm`|
50
+
|**[`threshold`](#threshold)**|`{Number}`|`0`| Only assets bigger than this size are processed (in bytes) |
51
+
|**[`minRatio`](#minratio)**|`{Number}`|`0.8`| Only assets that compress better than this ratio are processed (`minRatio = Compressed Size / Original Size`) |
52
+
|**[`filename`](#filename)**|`{String\|Function}`|`[path].gz[query]`| The target asset filename. |
Include all assets matching any of these conditions.
68
80
69
81
**webpack.config.js**
70
82
@@ -83,7 +95,7 @@ module.exports = {
83
95
Type: `String|RegExp|Array<String|RegExp>`
84
96
Default: `undefined`
85
97
86
-
Files to exclude.
98
+
Exclude all assets matching any of these conditions.
87
99
88
100
**webpack.config.js**
89
101
@@ -97,53 +109,6 @@ module.exports = {
97
109
};
98
110
```
99
111
100
-
### `filename`
101
-
102
-
Type: `String|Function`
103
-
Default: `[path].gz[query]`
104
-
105
-
The target asset filename.
106
-
107
-
#### `String`
108
-
109
-
`[file]` is replaced with the original asset filename.
110
-
`[path]` is replaced with the path of the original asset.
111
-
`[dir]` is replaced with the directory of the original asset.
112
-
`[name]` is replaced with the filename of the original asset.
113
-
`[ext]` is replaced with the extension of the original asset.
114
-
`[query]` is replaced with the query.
115
-
116
-
**webpack.config.js**
117
-
118
-
```js
119
-
module.exports= {
120
-
plugins: [
121
-
newCompressionPlugin({
122
-
filename:'[path].gz[query]',
123
-
}),
124
-
],
125
-
};
126
-
```
127
-
128
-
#### `Function`
129
-
130
-
**webpack.config.js**
131
-
132
-
```js
133
-
module.exports= {
134
-
plugins: [
135
-
newCompressionPlugin({
136
-
filename(info) {
137
-
// info.file is the original asset filename
138
-
// info.path is the path of the original asset
139
-
// info.query is the query
140
-
return`${info.path}.gz${info.query}`;
141
-
},
142
-
}),
143
-
],
144
-
};
145
-
```
146
-
147
112
### `algorithm`
148
113
149
114
Type: `String|Function`
@@ -190,9 +155,10 @@ module.exports = {
190
155
Type: `Object`
191
156
Default: `{ level: 9 }`
192
157
158
+
Compression options for `algorithm`.
159
+
193
160
If you use custom function for the `algorithm` option, the default value is `{}`.
194
161
195
-
Compression options.
196
162
You can find all options here [zlib](https://nodejs.org/api/zlib.html#zlib_class_options).
197
163
198
164
**webpack.config.js**
@@ -248,6 +214,53 @@ module.exports = {
248
214
};
249
215
```
250
216
217
+
### `filename`
218
+
219
+
Type: `String|Function`
220
+
Default: `[path].gz[query]`
221
+
222
+
The target asset filename.
223
+
224
+
#### `String`
225
+
226
+
`[file]` is replaced with the original asset filename.
227
+
`[path]` is replaced with the path of the original asset.
228
+
`[dir]` is replaced with the directory of the original asset.
229
+
`[name]` is replaced with the filename of the original asset.
230
+
`[ext]` is replaced with the extension of the original asset.
231
+
`[query]` is replaced with the query.
232
+
233
+
**webpack.config.js**
234
+
235
+
```js
236
+
module.exports= {
237
+
plugins: [
238
+
newCompressionPlugin({
239
+
filename:'[path].gz[query]',
240
+
}),
241
+
],
242
+
};
243
+
```
244
+
245
+
#### `Function`
246
+
247
+
**webpack.config.js**
248
+
249
+
```js
250
+
module.exports= {
251
+
plugins: [
252
+
newCompressionPlugin({
253
+
filename(info) {
254
+
// info.file is the original asset filename
255
+
// info.path is the path of the original asset
256
+
// info.query is the query
257
+
return`${info.path}.gz${info.query}`;
258
+
},
259
+
}),
260
+
],
261
+
};
262
+
```
263
+
251
264
### `deleteOriginalAssets`
252
265
253
266
Type: `Boolean`
@@ -272,7 +285,7 @@ module.exports = {
272
285
> ⚠ Ignored in webpack 5! Please use https://webpack.js.org/configuration/other-options/#cache.
273
286
274
287
Type: `Boolean|String`
275
-
Default: `false`
288
+
Default: `true`
276
289
277
290
Enable file caching.
278
291
The default path to cache directory: `node_modules/.cache/compression-webpack-plugin`.
@@ -348,7 +361,7 @@ module.exports = {
348
361
349
362
Node 10.16.0 and later has [native support](https://nodejs.org/api/zlib.html#zlib_zlib_createbrotlicompress_options) for Brotli compression in its zlib module.
350
363
351
-
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:
364
+
We 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:
0 commit comments