yuanjing/vite.config.ts
2026-09-20 13:49:49 +08:00

43 lines
981 B
TypeScript

import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath, URL } from 'node:url'
// https://vite.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const apiBaseURL = env.VITE_API_BASE_URL || 'https://token.opencomputing.cn'
return {
plugins: [vue(),],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
host: 'localhost',
port: 5173,
// 配置代理解决跨域问题
proxy: {
'/api': {
target: apiBaseURL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
'/token':{
target: apiBaseURL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/token/, ''),
}
}
},
// optimizeDeps: {
// exclude: ['@techui/scifi']
// },
}
})