vue_ts_large_rem/vue.config.js

46 lines
1.1 KiB
JavaScript
Raw Normal View History

const { defineConfig } = require('@vue/cli-service');
const WebpackBar = require('webpackbar');
const CompressionPlugin = require('compression-webpack-plugin');
module.exports = defineConfig({
transpileDependencies: true,
productionSourceMap: false, // 不生成map文件-优化打包
// 生产环境开启js\css压缩--- 打包优化
chainWebpack: config => {
if (process.env.NODE_ENV === 'production') {
config.plugin('compressionPlugin').use(
new CompressionPlugin({
test: /\.(js|css|less|map)$/, // 匹配文件名
threshold: 1024, // 对超过10k的数据压缩
minRatio: 0.8,
}),
);
}
},
// 代理设置
devServer: {
port: 6366,
open: true,
https: false,
proxy: {
'/api': {
target: process.env.VUE_APP_URL,
changeOrigin: true,
2024-02-28 20:09:27 +08:00
pathRewrite: { '^/api': '/api' },
},
2024-02-28 19:23:22 +08:00
'/mock': {
target: process.env.VUE_APP_URL,
changeOrigin: true,
2024-02-28 20:12:21 +08:00
pathRewrite: { '^/mock': '' },
2024-02-28 19:23:22 +08:00
},
},
},
configureWebpack: {
plugins: [
// 设置进度条颜色
new WebpackBar({ color: '#F6DCE0', profile: true }),
],
},
publicPath: process.env.NODE_ENV === 'production' ? './' : './',
});