Add Webpack Compression plugin in prod build

This commit is contained in:
Corentin 2021-10-07 17:15:37 +09:00
commit 5e21b9d8ff
2 changed files with 10 additions and 9 deletions

View file

@ -3,7 +3,6 @@ const fs = require('fs');
const marked = require('marked');
const CopyPlugin = require('copy-webpack-plugin');
// const CompressionPlugin = require("compression-webpack-plugin")
const renderer = new marked.Renderer()
renderer.link = (href, title, text) => {
@ -144,14 +143,7 @@ module.exports = {
{from: 'assets/icons', to: 'assets/icons'},
{from: 'assets/images', to: 'assets/images'},
{from: 'assets/theme', to: 'assets/theme'}
]}),
// new CompressionPlugin(
// {
// filename: "[path].gz[query]",
// algorithm: "gzip",
// test: [/\.js/, /\.svg/],
// threshold: 1000
// })
]})
],
output:
{

View file

@ -1,6 +1,9 @@
const webpack = require('webpack');
const config = require('./webpack.base.js');
const CompressionPlugin = require("compression-webpack-plugin")
module.exports = Object.assign(
config,
{
@ -16,6 +19,12 @@ module.exports = Object.assign(
{
'DEBUG': false
} // set a DEBUG flag that can be used in the scripts (can be skipped)
}),
new CompressionPlugin(
{
algorithm: "gzip",
test: [/\.js$/, /\.svg$/],
threshold: 1000
})
])
}