EasyAudioEncode/web/vite.config.ts
2025-12-25 17:01:46 +08:00

35 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react-swc'
import path from 'path'
// https://vite.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, path.resolve(process.cwd(), './'), '')
// console.log('当前环境:', mode)
// console.log('读取的.env变量', env.VITE_WEB_BASE_URL)
return {
plugins: [react()],
base: env.VITE_WEB_BASE_URL,
build: { outDir: "../internal/web/api/static/www" },
server: {
port: 5174,
proxy: {
// 代理所有 /api 请求到后端服务器
'/api': {
target: 'http://127.0.0.1:8089',
changeOrigin: true,
secure: false,
// 可选:重写路径
// rewrite: (path) => path.replace(/^\/api/, '')
},
'/uploads': {
target: 'http://127.0.0.1:8089',
changeOrigin: true,
secure: false,
// 可选:重写路径
// rewrite: (path) => path.replace(/^\/api/, '')
},
}
}
}
})