-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
101 lines (99 loc) · 2.46 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
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
99
100
101
import { ProxyOptions, defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import { fileURLToPath, URL } from 'node:url'
import AutoImport from 'unplugin-auto-import/vite'
import Icons from 'unplugin-icons/vite'
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())
const { VITE_PORT, VITE_BASE_API_PREFIX, VITE_BASE_API_URL } = env
const port = parseInt(VITE_PORT, 10) || 5173
const proxy: Record<string, string | ProxyOptions> = {
[VITE_BASE_API_PREFIX]: {
target: VITE_BASE_API_URL,
changeOrigin: true,
rewrite: (path: string) => path.replace(VITE_BASE_API_PREFIX, '')
}
// '/socket.io': {
// target: VITE_BASE_API_URL,
// ws: true,
// changeOrigin: true
// }
}
return {
plugins: [
react(),
AutoImport({
dts: '@types/auto-imports.d.ts',
include: [/\.[tj]sx?$/, /\.md$/],
imports: [
'react',
'react-router-dom',
{
from: '@tanstack/react-query',
imports: ['useQueryClient', 'useQuery', 'useQueries', 'useMutation', 'keepPreviousData']
},
{
from: 'clsx',
imports: [['default', 'clsx']]
},
{
from: 'use-immer',
imports: ['useImmer']
},
{
from: '@iconify/react',
imports: ['Icon']
},
{
from: '@/constants',
imports: ['AppMetadata', 'GlobalEnvConfig']
},
{
from: 'antd',
imports: ['Button', 'Input', 'Layout', 'Card', 'message']
},
{
from: 'zustand',
imports: ['create']
}
],
dirs: [
'src/api/**',
'src/components/**',
'src/hooks/**',
'src/layouts/*/index.tsx',
'src/providers/**',
'src/store/**',
'src/utils/**'
]
}),
Icons({
autoInstall: true,
compiler: 'jsx',
jsx: 'react'
})
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
esbuild: {
drop: mode === 'production' ? ['console', 'debugger'] : []
},
server: {
host: true,
port,
strictPort: true,
open: false,
proxy
},
preview: {
host: true,
port,
strictPort: true,
open: false,
proxy
}
}
})