Skip to content

Commit caf3e08

Browse files
wip(build): gen brotli and gzip versions
1 parent 19bcb85 commit caf3e08

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

build/webpack.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
const Path = require('path');
2+
const zlib = require("zlib");
23

34
const Webpack = require('webpack');
45
const TerserPlugin = require('terser-webpack-plugin');
56
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
67
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');
8+
const CompressionPlugin = require('compression-webpack-plugin');
79

810

911
// doc: https://github.com/Nyalab/caniuse-api#api
@@ -122,6 +124,22 @@ module.exports = (env = {}, { mode = 'production' }) => {
122124
] : [],
123125

124126
...isProd ? [
127+
new CompressionPlugin({
128+
filename: "[path][base].br",
129+
algorithm: "brotliCompress",
130+
compressionOptions: {
131+
params: {
132+
[zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY,
133+
},
134+
},
135+
}),
136+
new CompressionPlugin({
137+
filename: "[path][base].gz",
138+
algorithm: "gzip",
139+
compressionOptions: {
140+
level: 9,
141+
},
142+
}),
125143
new DuplicatePackageCheckerPlugin(),
126144
new BundleAnalyzerPlugin({
127145
// doc: https://github.com/webpack-contrib/webpack-bundle-analyzer#options-for-plugin

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"typescript": "^4.2.2",
8080
"webpack": "^5.24.3",
8181
"webpack-bundle-analyzer": "^4",
82+
"compression-webpack-plugin": "^7.1.2",
8283
"webpack-cli": "^4.5.0"
8384
}
8485
}

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,6 +2222,14 @@ component-emitter@^1.2.1:
22222222
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0"
22232223
integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==
22242224

2225+
compression-webpack-plugin@^7.1.2:
2226+
version "7.1.2"
2227+
resolved "https://registry.yarnpkg.com/compression-webpack-plugin/-/compression-webpack-plugin-7.1.2.tgz#f9a1ba84d4879693e29726f6884b382940876597"
2228+
integrity sha512-9DKNW6ILLjx+bNBoviHDgLx6swBhWWH9ApClC9sTH2NoFfQM47BapQfovCm9zjD9v1uZwInF5a925FB9ErGQeQ==
2229+
dependencies:
2230+
schema-utils "^3.0.0"
2231+
serialize-javascript "^5.0.1"
2232+
22252233
22262234
version "0.0.1"
22272235
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"

0 commit comments

Comments
 (0)