-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
59 lines (57 loc) · 1.67 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import react from '@vitejs/plugin-react';
import path from 'path';
import { loadEnv, type UserConfig } from 'vite';
import eslint from 'vite-plugin-eslint';
import { configDefaults, defineConfig } from 'vitest/config';
// https://vitejs.dev/config/
export default ({ mode }: UserConfig) => {
process.env = { ...process.env, ...loadEnv(mode ?? 'development', process.cwd()) };
return defineConfig({
esbuild: {
jsxFactory: 'h',
jsxFragment: 'Fragment',
},
server: {
// 代理设置查看 https://cn.vitejs.dev/config/server-options.html#server-proxy
proxy: {
// 访问 /api/test 等价于访问 http://localhost:3305/api/test
'/api': {
target: 'http://localhost:3305/',
changeOrigin: true,
},
},
port: 3006,
},
test: {
// 使用类似 jest 中的全局 API
globals: true,
setupFiles: 'tests/libs/setup.ts',
// 匹配排除测试文件的 glob 规则。
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/.{idea,git,cache,output,temp}/**',
'mock/*',
],
// 匹配包含测试文件的 glob 规则。
include: [...configDefaults.include, 'tests/files/**/*.test.ts?x'],
useAtomics: true, // 同步线程
environment: 'happy-dom',
coverage: {
reporter: ['text', 'json', 'html'],
},
typecheck: {
tsconfig: './tsconfig.json',
},
deps: {
inline: ['echarts'],
},
},
plugins: [react(), eslint() as any],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'), // 映射的目录必须以/开头,表示根目录
},
},
});
};