-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
42 lines (40 loc) · 1.21 KB
/
vite.config.ts
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
import { resolve } from 'path'
import { defineConfig, loadEnv } from 'vite'
import { createVitePlugins } from './plugins'
import { wrapEnv } from './plugins/utils'
// https://vitejs.dev/config/
// export default defineConfig(({ command, mode }) => {
export default defineConfig(({ mode }) => {
const env = wrapEnv(loadEnv(mode, process.cwd()))
return {
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
plugins: createVitePlugins(env),
build: {
minify: 'terser',
terserOptions: {
compress: {
// 生产环境时移除console
drop_console: true,
drop_debugger: true,
},
},
},
// 开发服务器选项
server: {
host: env.VITE_HOST ?? 'localhost',
port: env.VITE_PORT ?? '8368',
proxy: {
// 配置 api 代理解决跨域问题
'/api': {
target: env.VITE_BASE_API,
changeOrigin: true,
rewrite: p => p.replace(/^\/api/, ''),
},
},
},
}
})