Skip to content

Commit

Permalink
feat: compress assets using gzip
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki committed Mar 31, 2023
1 parent 40b7b06 commit f9537c2
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
31 changes: 31 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"aegir": "^38.1.8",
"babel-cli": "^6.26.0",
"babel-loader": "^9.1.2",
"compression-webpack-plugin": "^10.0.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.3",
"dexie": "^3.2.3",
Expand Down
15 changes: 14 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { fileURLToPath } from 'url'
import CopyWebpackPlugin from 'copy-webpack-plugin'
import NodePolyfillPlugin from 'node-polyfill-webpack-plugin'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import CompressionPlugin from 'compression-webpack-plugin'
// import {GenerateSW} from 'workbox-webpack-plugin';
import zlib from 'zlib'

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

Expand Down Expand Up @@ -62,7 +64,7 @@ const prod = {
})
})
}
}
},
]
}

Expand Down Expand Up @@ -150,6 +152,17 @@ const common = {

new webpack.DefinePlugin({
window: 'globalThis' // attempt to naively replace all "window" keywords with "globalThis"
}),
new CompressionPlugin({
algorithm: 'gzip',
test: /\.(js|css|html|svg)$/,
exclude: /.map$/,
compressionOptions: {
level: 9,
numiterations: 15,
minRatio: 0.8,
deleteOriginalAssets: true,
}
})
],

Expand Down

0 comments on commit f9537c2

Please sign in to comment.