-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
45 lines (41 loc) · 1.1 KB
/
Copy pathvite.config.js
File metadata and controls
45 lines (41 loc) · 1.1 KB
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
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
const normalizeBase = (rawBase) => {
if (!rawBase || rawBase === '/') {
return '/'
}
const withLeadingSlash = rawBase.startsWith('/') ? rawBase : `/${rawBase}`
return withLeadingSlash.endsWith('/') ? withLeadingSlash : `${withLeadingSlash}/`
}
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const proxyTarget = env.VITE_API_PROXY_TARGET || 'http://127.0.0.1:3001'
const useLocalProxy = !env.VITE_API_BASE_URL
return {
base: normalizeBase(env.VITE_BASE_PATH),
plugins: [react()],
server: {
port: 5173,
open: true,
proxy: useLocalProxy ? {
'/health': {
target: proxyTarget,
changeOrigin: true,
},
'/api': {
target: proxyTarget,
changeOrigin: true,
},
'/assets': {
target: proxyTarget,
changeOrigin: true,
},
} : undefined,
},
build: {
target: 'esnext',
minify: 'terser',
assetsDir: '_assets',
},
}
})