-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
41 lines (38 loc) · 1.18 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
import dotenv from 'dotenv';
import pluginRewriteAll from 'vite-plugin-rewrite-all';
dotenv.config();
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import monacoEditorPlugin from 'vite-plugin-monaco-editor';
const {
BACKEND_PORT = 3001,
BACKEND_HOSTNAME = 'localhost',
BACKEND_TEMPLATE_HOSTNAME = 'localhost',
BACKEND_TEMPLATE_PORT = 3002,
} = process.env;
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
// https://github.com/vdesjs/vite-plugin-monaco-editor/issues/21
monacoEditorPlugin.default({}),
// Vite plugin that fix dev server not rewriting the path includes a dot vite#2190
pluginRewriteAll()
],
server: {
proxy: {
'/api/backend': {
target: `http://${BACKEND_HOSTNAME}:${BACKEND_PORT}/`,
changeOrigin: false,
autoRewrite: true,
rewrite: (path) => path.replace(/^\/api\/backend/, '/api'),
},
'/api/template': {
target: `http://${BACKEND_TEMPLATE_HOSTNAME}:${BACKEND_TEMPLATE_PORT}/`,
changeOrigin: false,
autoRewrite: true,
rewrite: (path) => path.replace(/^\/api\/template/, '/template'),
}
},
},
})