-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
98 lines (95 loc) · 2.7 KB
/
vue.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
const { defineConfig } = require('@vue/cli-service');
const CompressionWebpackPlugin = require('compression-webpack-plugin');
const mockApi = require('./mock');
/* const isProd = process.env.NODE_ENV === 'production';
const assetsCDN = {
externals: {
vue: 'vue',
'vue-router': 'vue-router',
},
css: [],
js: [
'//cdn.jsdelivr.net/npm/vue@3.2.13/dist/vue.global.prod.js',
'//cdn.jsdelivr.net/npm/vue-router@4.0.3/dist/vue-router.global.prod.js',
// '//cdn.jsdelivr.net/npm/vuex@4.0.0/dist/vuex.global.prod.js',
],
}; */
module.exports = defineConfig({
transpileDependencies: false,
productionSourceMap: false,
css: {
loaderOptions: {
less: {
lessOptions: {
modifyVars: {
/* 'primary-color': '#1DA57A',
'link-color': '#1DA57A',
'border-radius-base': '2px', */
},
javascriptEnabled: true,
},
},
},
},
devServer: {
open: true,
host: 'local-ip',
client: {
// logging: 'info', // 日志
overlay: { // 编译错误或警告时 是否全屏显示
errors: true,
warnings: false,
},
// progress: true, // 在浏览器百分比显示编译进度
// 指定 URL 到 web socket 服务器
// To get protocol/hostname/port from browser
webSocketURL: 'auto://0.0.0.0:0/ws',
/* webSocketURL: {
hostname: '0.0.0.0', // 不是真正意义上的IP 是一个本地ip的集合
pathname: '/ws',
port: 0, // 指定port 只在port相同时 会热更新
}, */
},
proxy: {
'/api': {
// target: 'http://127.0.0.1:4523', // dev
target: 'http://127.0.0.1:7001', // dev
changeOrigin: true,
pathRewrite: {
'^/api': '',
},
},
},
// 详细配置参考 https://webpack.docschina.org/configuration/dev-server/#devserversetupmiddlewares
// mock数据
setupMiddlewares: (middlewares, devServer) => {
if (!devServer) {
throw new Error('webpack-dev-server is not defined');
}
mockApi.dashboard.getList(devServer);
return middlewares;
},
},
configureWebpack: {
plugins: [
// 压缩成 .gz 文件
new CompressionWebpackPlugin({
filename: '[path][base].gz',
algorithm: 'gzip',
test: /\.js$|\.css$|\.html$/,
threshold: 10240, // 压缩限制
minRatio: 0.8, // 压缩率
deleteOriginalAssets: false, // 删除源文件
}),
],
// externals: isProd ? assetsCDN.externals : {},
},
/* chainWebpack: (config) => {
if (isProd) {
config.plugin('html').tap((args) => {
args[0].cdn = assetsCDN;
return args;
});
}
}, */
});