-
Notifications
You must be signed in to change notification settings - Fork 186
/
vite.config.js
88 lines (83 loc) · 2.79 KB
/
vite.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
import path, { resolve } from 'path'
import { defineConfig } from "vite"
import vue from "@vitejs/plugin-vue"
import viteSvgIcons from 'vite-plugin-svg-icons'
import externalGlobals from 'rollup-plugin-external-globals'
export default defineConfig(({ command }) => {
const proxyTarget = 'http://xxooo.online'
let vueI18n = {}
if (command === "serve") {
vueI18n["vue-i18n"] = "vue-i18n/dist/vue-i18n.cjs.js" //解决dev运行警告You are running the esm-bundler build of vue-i18n.
}
return {
base: "./",
define: {
'process.platform': null,
'process.version': null
},
plugins: [
vue(),
viteSvgIcons({
// 指定需要缓存的图标文件夹(可以配置多个)
iconDirs: [path.resolve(process.cwd(), 'src/icons/svg')],
// 指定symbolId格式
symbolId: 'icon-[name]'
})
],
resolve: {
alias: {
'~': resolve(__dirname, './'),
'@': resolve(__dirname, 'src'),
...vueI18n
},
extensions: ['.js', '.ts', '.jsx', '.tsx', '.json', '.vue', '.mjs']
},
server: {
host: "127.0.0.1",
port: 5173,
open: true,
// 反向代理
proxy: {
"/api": {
target: proxyTarget,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, "")
},
"/ws": {
target: proxyTarget,
changeOrigin: true,
ws: true,
rewrite: (path) => path.replace(/^\/ws/, "")
},
}
},
build: {
assetsDir: 'static',
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true
}
},
rollupOptions:{
external: ['vue', 'vuex', 'vue-i18n', 'vue-router', 'element-plus',
'axios', 'crypto-js', 'dayjs', 'easyqrcodejs', 'nprogress'],
plugins: [
externalGlobals({
vue: 'Vue',
vuex: 'Vuex',
'vue-i18n': 'VueI18n',
'vue-router': 'VueRouter',
axios: 'axios',
'crypto-js': 'CryptoJS',
'dayjs': 'dayjs',
'easyqrcodejs': 'QRCode',
'nprogress': 'NProgress',
'element-plus': 'ElementPlus'
}),
]
}
}
}
})