This commit is contained in:
dcr_xuxgc
2026-06-12 17:49:54 +08:00
commit d759a9e740
69 changed files with 14243 additions and 0 deletions

36
vite.config.js Normal file
View File

@@ -0,0 +1,36 @@
import { fileURLToPath } from 'url'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
// Vite 配置
export default defineConfig(({ mode }) => {
// 加载环境变量
const env = loadEnv(mode, process.cwd(), '')
return {
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
port: 5173,
proxy: {
'/api': {
// 本地开发模式VITE_SERVER_URL 为空或本地地址时使用代理
target: env.VITE_SERVER_URL || `http://localhost:${env.VITE_API_PORT || '3000'}`,
changeOrigin: true,
// 仅远程部署时改变 origin
configure: (proxy) => {
if (env.VITE_SERVER_URL && !env.VITE_SERVER_URL.includes('localhost')) {
proxy.on('proxyReq', (proxyReq) => {
proxyReq.setHeader('origin', env.VITE_SERVER_URL)
})
}
}
}
}
}
}
})