Skip to content

Commit 4d5b67d

Browse files
perf(webpack): generate gzip, brotli compressed bundles
1 parent b588bea commit 4d5b67d

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
"babel-plugin-react-remove-properties": "^0.3.0",
149149
"babel-plugin-transform-import-meta": "^2.2.1",
150150
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
151+
"compression-webpack-plugin": "^11.1.0",
151152
"css-loader": "^6.11.0",
152153
"cssnano": "^6.1.2",
153154
"dotenv-webpack": "^8.0.1",

client/webpack.prod.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ const { merge } = require('webpack-merge');
22
const TerserPlugin = require('terser-webpack-plugin');
33
const MomentTimezoneDataPlugin = require('moment-timezone-data-webpack-plugin');
44
const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');
5+
const CompressionPlugin = require('compression-webpack-plugin');
6+
const zlib = require('zlib');
57

68
const common = require('./webpack.common');
79

@@ -67,5 +69,19 @@ module.exports = merge(common, {
6769
implementation: ImageMinimizerPlugin.svgoMinify,
6870
},
6971
}),
72+
new CompressionPlugin({
73+
test: /\.(js|css|html|svg|png)$/,
74+
algorithm: 'gzip',
75+
}),
76+
new CompressionPlugin({
77+
algorithm: 'brotliCompress',
78+
test: /\.(js|css|html|svg|png)$/,
79+
compressionOptions: {
80+
params: {
81+
[zlib.constants.BROTLI_PARAM_QUALITY]: 11,
82+
},
83+
},
84+
threshold: 10240,
85+
}),
7086
],
7187
});

client/yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4262,6 +4262,14 @@ compressible@~2.0.16:
42624262
dependencies:
42634263
mime-db ">= 1.43.0 < 2"
42644264

4265+
compression-webpack-plugin@^11.1.0:
4266+
version "11.1.0"
4267+
resolved "https://registry.yarnpkg.com/compression-webpack-plugin/-/compression-webpack-plugin-11.1.0.tgz#ee340d2029cf99ccecdea9ad1410b377d15b48b3"
4268+
integrity sha512-zDOQYp10+upzLxW+VRSjEpRRwBXJdsb5lBMlRxx1g8hckIFBpe3DTI0en2w7h+beuq89576RVzfiXrkdPGrHhA==
4269+
dependencies:
4270+
schema-utils "^4.2.0"
4271+
serialize-javascript "^6.0.2"
4272+
42654273
compression@^1.7.4:
42664274
version "1.7.4"
42674275
resolved "https://registry.yarnpkg.com/compression/-/compression-1.7.4.tgz#95523eff170ca57c29a0ca41e6fe131f41e5bb8f"

0 commit comments

Comments
 (0)