How to configure:
NPM I compression webpack plugin - d
install the plug-in and add the following configuration in Vue.Config.JS
(the compression plugin configuration options depend on your personal needs)
configureWebpack: {
plugins: [
new CompressionPlugin({
test: /\.(js|css)?$/i, // Which files to compress
algorithm:'gzip', // Use gzip compression
})
]
}
Problems:
usegzip
to unzip the Vue project report an error:Error: Rule can only have one resource source (provided resource and test + include + exclude).
Cause Analysis:
Webpack version conflict in package.json
Solution:
npm i compression-webpack-plugin@6.1.1 -D
npm i webpack@4.44.2 webpack-cli@4.2.0 -D