-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
60 lines (58 loc) · 1.75 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
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import * as path from 'path';
export default ({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
process.env = Object.assign(process.env, loadEnv(mode, process.cwd(), ''));
return defineConfig({
envPrefix: 'REACT_APP_',
plugins: [react()],
server: {
proxy: {
'/ocr': {
target: process.env.REACT_APP_OCR_API_INVOKE,
changeOrigin: true,
secure: false,
ws: true,
rewrite: (path) => path.replace(/^\/ocr/, ''),
},
'/api': {
target: process.env.REACT_APP_GPT_API_INVOKE,
changeOrigin: true,
secure: false,
ws: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
port: 3000,
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
define: {
'process.env.REACT_APP_OCR_API_INVOKE': JSON.stringify(
env.REACT_APP_OCR_API_INVOKE,
),
'process.env.REACT_APP_GPT_API_INVOKE': JSON.stringify(
env.REACT_APP_GPT_API_INVOKE,
),
'process.env.REACT_APP_OCR_API_GATEWAY': JSON.stringify(
env.REACT_APP_OCR_API_GATEWAY,
),
'process.env.REACT_APP_OCR_API_KEY': JSON.stringify(
env.REACT_APP_OCR_API_KEY,
),
'process.env.REACT_APP_GPT_API_GATEWAY': JSON.stringify(
env.REACT_APP_GPT_API_GATEWAY,
),
'process.env.REACT_APP_GPT_API_GETRESULT_NUTRITIONIST': JSON.stringify(
env.REACT_APP_GPT_API_GETRESULT_NUTRITIONIST,
),
'process.env.REACT_APP_GPT_API_GETRESULT_CHEMIST': JSON.stringify(
env.REACT_APP_GPT_API_GETRESULT_CHEMIST,
),
},
});
};