vue first screen optimized loading (2) (Gzip compression)

# 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",


# Reinstall npm version 1.1.11 plugin



# Then run npm run build to package

Posted 34 original articles · liked 0 · visits 513

Guess you like

Origin blog.csdn.net/weixin_42863549/article/details/104609035