# Install compression-webpack-plugin development dependent plugin
npm install --save-dev compression-webpack-plugin
# Go to config / index.js in the root directory, change productionSourceMap: to false, and productionGzip to true
productionSourceMap: false,
// https://webpack.js.org/configuration/devtool/#production
devtool: '#source-map',
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: true,
productionGzipExtensions: ['js', 'css'],
# If you run npm run build at this time, you will get an error
ValidationError: Compression Plugin Invalid Options
options should NOT have additional properties
# This is due to the version problem, in the project package.json will
"compression-webpack-plugin": "^3.0.0",
Downgrade to
"compression-webpack-plugin": "^1.1.11",