#
luxiaotao1123
2024-11-12 ce7cab3f73e46f76b10efd7f8ff8dd5ce712482b
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
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import { resolve } from 'path';
 
// https://vitejs.dev/config/
// export default defineConfig({
//   plugins: [react()],
//   resolve: {
//     alias: {
//       '@/': resolve('src') + '/'
//     }
//   },
//   server: {
//     port: 5000,
//     host: '0.0.0.0',
//     proxy: {
//       '/api': {
//         target: 'http://192.168.4.53:8088',
//         changeOrigin: true,
//         rewrite: (path) => path.replace(/^\/api/, ''),
//       },
//     },
//   },
//   base: './',
//   envPrefix: "COOL_",
// });
 
// 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',
      proxy: {
        '/api': {
          target: `http://${env.COOL_BASE_IP}:${env.COOL_BASE_PORT}`,
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, ''),
        },
      },
    },
    base: './',
    envPrefix: 'COOL_',
  };
});