webpack 代理配置
修改vue.config.js
module.exports={ ... // 代理相关配置 devServer: { host: '0.0.0.0', port: 8080, https: false, hotOnly: false, proxy: null, // string | Object }, ... }
打包文件优化
1.安装插件
- uglifyjs-webpack-plugin //去除console
// vue.config.js const UglifyJsPlugin = require('uglifyjs-webpack-plugin') const isProd = process.env.NODE_ENV === "production" module.exports = { configureWebpack: { optimization: { minimizer: isProd ? [ new UglifyJsPlugin({ uglifyOptions: { compress: { drop_console: true }, } }) ] : [] } } }
- compression-webpack-plugin //gzip压缩