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
@@ -194,11 +235,16 @@ If you use custom function for the `algorithm` option, the default value is `{}`
194
235
Compression options.
195
236
You can find all options here [zlib](https://nodejs.org/api/zlib.html#zlib_class_options).
196
237
238
+
**webpack.config.js**
239
+
197
240
```js
198
-
// in your webpack.config.js
199
-
newCompressionPlugin({
200
-
compressionOptions: { level:1 },
201
-
});
241
+
module.exports= {
242
+
plugins: [
243
+
newCompressionPlugin({
244
+
compressionOptions: { level:1 },
245
+
}),
246
+
],
247
+
};
202
248
```
203
249
204
250
### `threshold`
@@ -208,11 +254,16 @@ Default: `0`
208
254
209
255
Only assets bigger than this size are processed. In bytes.
210
256
257
+
**webpack.config.js**
258
+
211
259
```js
212
-
// in your webpack.config.js
213
-
newCompressionPlugin({
214
-
threshold:8192,
215
-
});
260
+
module.exports= {
261
+
plugins: [
262
+
newCompressionPlugin({
263
+
threshold:8192,
264
+
}),
265
+
],
266
+
};
216
267
```
217
268
218
269
### `minRatio`
@@ -225,11 +276,16 @@ Example: you have `image.png` file with 1024b size, compressed version of file h
225
276
In other words assets will be processed when the `Compressed Size / Original Size` value less `minRatio` value.
226
277
You can use `1` value to process assets that are smaller than the original. Use a value of Number.MAX_SAFE_INTEGER to process all assets even if they are larger than the original (useful when you are pre-zipping all assets for AWS)
227
278
279
+
**webpack.config.js**
280
+
228
281
```js
229
-
// in your webpack.config.js
230
-
newCompressionPlugin({
231
-
minRatio:0.8,
232
-
});
282
+
module.exports= {
283
+
plugins: [
284
+
newCompressionPlugin({
285
+
minRatio:0.8,
286
+
}),
287
+
],
288
+
};
233
289
```
234
290
235
291
### `deleteOriginalAssets`
@@ -239,11 +295,16 @@ Default: `false`
239
295
240
296
Whether to delete the original assets or not.
241
297
298
+
**webpack.config.js**
299
+
242
300
```js
243
-
// in your webpack.config.js
244
-
newCompressionPlugin({
245
-
deleteOriginalAssets:true,
246
-
});
301
+
module.exports= {
302
+
plugins: [
303
+
newCompressionPlugin({
304
+
deleteOriginalAssets:true,
305
+
}),
306
+
],
307
+
};
247
308
```
248
309
249
310
## Examples
@@ -283,20 +344,25 @@ module.exports = {
283
344
284
345
[Brotli](https://en.wikipedia.org/wiki/Brotli) is a compression algorithm originally developed by Google, and offers compression superior to gzip.
285
346
286
-
Node 11.7.0 and later has [native support](https://nodejs.org/api/zlib.html#zlib_zlib_createbrotlicompress_options) for Brotli compression in its zlib module.
347
+
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.
287
348
288
349
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:
0 commit comments