1
verou
2025-03-25 0d3a5be1512815a38f37ae81e7d9fc0948fd3f16
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 { 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: 8122,
      host: '0.0.0.0',
      // available in run dev
      proxy: {
        '/rsf-server': {
          target: `http://${env.VITE_BASE_IP}:${env.VITE_BASE_PORT}`,
          changeOrigin: true,
          bypass: (req, res, options) => {
            const proxyUrl = `${options.target}${req.url}`;
            res.setHeader('x-rel-url', proxyUrl);
          }
          // rewrite: (path) => path.replace(/^\/api/, ''),
        },
        '/ws': {
          target: `ws://${env.VITE_BASE_IP}:${env.VITE_BASE_PORT}`,
          changeOrigin: true,
          ws: true,
        },
      },
    },
    base: './',
    envPrefix: 'VITE_',
    open: true,
    cors: true,
  };
});