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 * as path from 'path'
| import createVitePlugins from './vite/plugins/index';
|
| // https://vitejs.dev/config/
| export default defineConfig(({mode, command}) => {
| const env = loadEnv(mode, process.cwd())
| let base = env.VITE_APP_BASE_URL ?? './';
| let baseServerApi = env.VITE_APP_BASE_SERVER_API;
| return {
| base: base,baseServerApi: baseServerApi,
| plugins: createVitePlugins(env, command === "build"),
| resolve: {
| alias: {
| '~': path.resolve(__dirname, './'),
| '@': path.resolve(__dirname, './src')
| },
| extensions: ['.mjs', '.js', '.ts', 'jsx', 'tsx', '.json', '.vue']
| },
| server: {
| port: 8081,
| host: true,
| open: true,
| proxy: {
| '/dev-api': {
| target: baseServerApi,
| changeOrigin: true,
| rewrite: (p) => p.replace(/^\/dev-api/, "")
| },
| '/ws': {
| target: baseServerApi,
| changeOrigin: true,
| ws: true, // 启用WebSocket代理
| }
| }
| },
| optimizeDeps: {
| exclude: ['node_modules']
| },
| }
| })
|
|