Skip to content
Permalink
Browse files
do gzip and brotli compression in webpack
  • Loading branch information
LeoMcA authored and akatsoulas committed Mar 10, 2022
1 parent 3ee63f0 commit 1458e71
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 1 deletion.
@@ -410,7 +410,7 @@ def parse_conn_max_age(value):
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
)

STATICFILES_STORAGE = "whitenoise.storage.CompressedStaticFilesStorage"
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.StaticFilesStorage"


def immutable_file_test(path, url):

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

@@ -49,6 +49,7 @@
"chai": "^4.3.4",
"chai-lint": "0.1.1",
"color-string": "^1.9.0",
"compression-webpack-plugin": "^9.2.0",
"concurrently": "^7.0.0",
"copy-webpack-plugin": "^10.2.0",
"css-loader": "^6.5.1",
@@ -1,5 +1,7 @@
const { mergeWithCustomize, unique } = require("webpack-merge");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CompressionPlugin = require("compression-webpack-plugin");
const zlib = require("zlib");

const dev = require("./webpack.dev.js");

@@ -15,6 +17,27 @@ module.exports = mergeWithCustomize({
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css",
}),
new CompressionPlugin({
algorithm: "gzip",
filename: "[path][base].gz",
compressionOptions: {
params: {
level: 9,
},
},
minRatio: 0.9,
}),
new CompressionPlugin({
algorithm: "brotliCompress",
filename: "[path][base].br",
compressionOptions: {
params: {
[zlib.constants.BROTLI_PARAM_QUALITY]:
zlib.constants.BROTLI_MAX_QUALITY,
},
},
minRatio: 0.9,
}),
],
cache: false,
devtool: false,

0 comments on commit 1458e71

Please sign in to comment.