-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
47 lines (45 loc) · 1.3 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
import { defineConfig, loadEnv, ConfigEnv } from 'vite'
import path from 'path'
import react from '@vitejs/plugin-react'
export default ({ mode }: ConfigEnv) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd(), 'REACT_') }
return defineConfig({
base: './',
envPrefix: 'REACT_',
build: {
outDir: 'build',
emptyOutDir: true
},
plugins: [react()],
resolve: {
alias: {
'@components': path.resolve(__dirname, './renderer/components'),
'@config': path.resolve(__dirname, './renderer/config'),
'@graphql': path.resolve(__dirname, './renderer/graphql'),
'@hooks': path.resolve(__dirname, './renderer/hooks'),
'@store': path.resolve(__dirname, '/renderer/store')
}
},
server: {
host: 'localhost',
port: 3000,
https: false,
cors: true,
hmr: true,
proxy: {
'/graphql': {
target: process.env.REACT_APP_GRAPHQL_URL,
changeOrigin: true,
secure: false,
rewrite: (url: string) => url.replace(/^\/graphql/, 'graphql')
},
'/api': {
target: process.env.REACT_APP_GRAPHQL_URL,
changeOrigin: true,
secure: false,
rewrite: (url: string) => url.replace(/^\/api/, 'api')
}
}
}
})
}