Skip to content

Commit f9537c2

Browse files
committed
feat: compress assets using gzip
1 parent 40b7b06 commit f9537c2

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

package-lock.json

+31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"aegir": "^38.1.8",
6363
"babel-cli": "^6.26.0",
6464
"babel-loader": "^9.1.2",
65+
"compression-webpack-plugin": "^10.0.0",
6566
"copy-webpack-plugin": "^11.0.0",
6667
"css-loader": "^6.7.3",
6768
"dexie": "^3.2.3",

webpack.config.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import { fileURLToPath } from 'url'
55
import CopyWebpackPlugin from 'copy-webpack-plugin'
66
import NodePolyfillPlugin from 'node-polyfill-webpack-plugin'
77
import HtmlWebpackPlugin from 'html-webpack-plugin'
8+
import CompressionPlugin from 'compression-webpack-plugin'
89
// import {GenerateSW} from 'workbox-webpack-plugin';
10+
import zlib from 'zlib'
911

1012
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1113

@@ -62,7 +64,7 @@ const prod = {
6264
})
6365
})
6466
}
65-
}
67+
},
6668
]
6769
}
6870

@@ -150,6 +152,17 @@ const common = {
150152

151153
new webpack.DefinePlugin({
152154
window: 'globalThis' // attempt to naively replace all "window" keywords with "globalThis"
155+
}),
156+
new CompressionPlugin({
157+
algorithm: 'gzip',
158+
test: /\.(js|css|html|svg)$/,
159+
exclude: /.map$/,
160+
compressionOptions: {
161+
level: 9,
162+
numiterations: 15,
163+
minRatio: 0.8,
164+
deleteOriginalAssets: true,
165+
}
153166
})
154167
],
155168

0 commit comments

Comments
 (0)