-
Notifications
You must be signed in to change notification settings - Fork 8
/
vite.config.js
70 lines (69 loc) · 1.7 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
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { createHtmlPlugin } from 'vite-plugin-html'
import { loadEnv } from 'vite'
import { fileURLToPath, URL } from 'url'
import legacy from '@vitejs/plugin-legacy'
import UnoCSS from 'unocss/vite'
/**
* @type {import('vite').UserConfig}
*/
export default ({ command, mode }) => {
const root = process.cwd()
const env = loadEnv(mode, root)
const isBuild = command === 'build'
const packageVersion = process.env.VITE_ENV_version || process.env.npm_package_version
return {
plugins: [
vue(),
vueJsx(),
UnoCSS(),
createHtmlPlugin({
inject: {
data: {
title: env.VITE_APP_TITLE,
basePath: env.VITE_APP_BASE_PATH
}
},
minify: isBuild
}),
legacy({
targets: ['defaults', 'not IE 11']
})
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
define: {
__VERSION__: JSON.stringify(packageVersion)
},
// base: './',
base: process.env.UI_BASE_PATH ? process.env.UI_BASE_PATH : './',
server: {
proxy: {
'/v1': {
target: 'http://localhost:8080',
ws: true
},
'/meta/proxy': {
target: 'http://localhost:8080'
},
'/k8s/proxy': {
target: 'http://localhost:8080'
}
}
},
build: {
outDir: 'dist/static'
},
test: {
// 启用类似 jest 的全局测试 API
globals: true,
// 使用 happy-dom 模拟 DOM
// 这需要你安装 happy-dom 作为对等依赖(peer dependency)
environment: 'happy-dom'
}
}
}