-
Notifications
You must be signed in to change notification settings - Fork 15
/
vite.config.ts
87 lines (83 loc) · 2.54 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
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import { fileURLToPath, URL } from 'url'
export default ({ mode }) => {
Object.assign(process?.env, loadEnv(mode, process?.cwd(), ''))
let SERVER_URL = 'http://localhost:5000'
// use .env if valid
if (process?.env?.SERVER_URL) {
SERVER_URL = process.env.SERVER_URL
}
// https://vitejs.dev/config/
return defineConfig({
server: {
proxy: {
'/api': {
target: SERVER_URL,
changeOrigin: true,
},
'/ws': {
target: SERVER_URL,
changeOrigin: true,
ws: true,
},
'/addons': {
target: SERVER_URL,
changeOrigin: false,
},
'/graphql': {
target: SERVER_URL,
changeOrigin: true,
},
'/graphiql': {
target: SERVER_URL,
changeOrigin: true,
},
'/docs': {
target: SERVER_URL,
changeOrigin: true,
},
'/openapi.json': {
target: SERVER_URL,
changeOrigin: true,
},
'/static': {
target: SERVER_URL,
changeOrigin: true,
},
'/openapi': {
target: SERVER_URL,
changeOrigin: true,
},
},
},
plugins: [react()],
resolve: {
alias: [
{ find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) },
{
find: '@containers',
replacement: fileURLToPath(new URL('./src/containers', import.meta.url)),
},
{ find: '@hooks', replacement: fileURLToPath(new URL('./src/hooks', import.meta.url)) },
{
find: '@components',
replacement: fileURLToPath(new URL('./src/components', import.meta.url)),
},
{ find: '@api', replacement: fileURLToPath(new URL('./src/api', import.meta.url)) },
{
find: '@types',
replacement: fileURLToPath(new URL('./src/types', import.meta.url)),
},
{
find: '@queries',
replacement: fileURLToPath(new URL('./src/services', import.meta.url)),
},
{ find: '@pages', replacement: fileURLToPath(new URL('./src/pages', import.meta.url)) },
{ find: '@context', replacement: fileURLToPath(new URL('./src/context', import.meta.url)) },
{ find: '@state', replacement: fileURLToPath(new URL('./src/features', import.meta.url)) },
{ find: '@helpers', replacement: fileURLToPath(new URL('./src/helpers', import.meta.url)) },
],
},
})
}