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
  | import { defineConfig, loadEnv } from 'vite'; 
 |  import react from '@vitejs/plugin-react'; 
 |  import { resolve } from 'path'; 
 |    
 |  // https://vitejs.dev/config/ 
 |  export default defineConfig(({ mode }) => { 
 |    const env = loadEnv(mode, process.cwd()); 
 |    return { 
 |      plugins: [react()], 
 |      resolve: { 
 |        alias: { 
 |          '@/': resolve('src') + '/', 
 |        }, 
 |      }, 
 |      server: { 
 |        port: 5000, 
 |        host: '0.0.0.0', 
 |        // available in run dev 
 |        proxy: { 
 |          '/api': { 
 |            target: `http://${env.VITE_BASE_IP}:${env.VITE_BASE_PORT}`, 
 |            changeOrigin: true, 
 |            // rewrite: (path) => path.replace(/^\/api/, ''), 
 |          }, 
 |          '/ws': { 
 |            target: `ws://${env.VITE_BASE_IP}:${env.VITE_BASE_PORT}`, 
 |            changeOrigin: true, 
 |            ws: true, 
 |          }, 
 |        }, 
 |      }, 
 |      base: './', 
 |      envPrefix: 'VITE_', 
 |    }; 
 |  }); 
 |  
  |