39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
|
const CompressionPlugin = require('compression-webpack-plugin');
|
||
|
|
||
|
module.exports = {
|
||
|
devServer: {
|
||
|
host: '127.0.0.1',
|
||
|
port: 9999,
|
||
|
proxy: {
|
||
|
'/xnzt': {
|
||
|
target: 'http://127.0.0.1:8080', // 请求本地 需要xboot后台项目
|
||
|
ws: true,
|
||
|
changeOrigin: true,
|
||
|
pathRewrite: {
|
||
|
// 路径重写
|
||
|
'^/xnzt': '' // 用'/api'代替target里面的地址
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
// 打包时不生成.map文件 避免看到源码
|
||
|
productionSourceMap: false,
|
||
|
// 部署优化
|
||
|
configureWebpack: {
|
||
|
// 使用CDN
|
||
|
externals: {
|
||
|
vue: 'Vue',
|
||
|
axios: 'axios',
|
||
|
'vue-router': 'VueRouter',
|
||
|
iview: 'iview'
|
||
|
},
|
||
|
// GZIP压缩
|
||
|
plugins: [
|
||
|
new CompressionPlugin({
|
||
|
test: /\.js$|\.html$|\.css/, // 匹配文件
|
||
|
threshold: 10240 // 对超过10k文件压缩
|
||
|
})
|
||
|
]
|
||
|
}
|
||
|
}
|