Files
Aether/frontend/vite.config.ts
2025-12-10 20:52:44 +08:00

72 lines
2.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 } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
// https://vite.dev/config/
export default defineConfig(({ mode }) => ({
// GitHub Pages 部署时使用仓库名作为 base
base: process.env.GITHUB_PAGES === 'true' ? '/Aether/' : '/',
plugins: [vue()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
build: {
// 使用 esbuild 进行压缩(默认)
minify: 'esbuild',
rollupOptions: {
output: {
// 手动分块以优化加载性能
manualChunks: {
// Vue 核心库
'vue-vendor': ['vue', 'vue-router', 'pinia'],
// UI 组件库
'ui-vendor': ['radix-vue', 'lucide-vue-next'],
// 工具库
'utils-vendor': ['axios', 'marked', 'dompurify'],
// 图表库
'chart-vendor': ['chart.js', 'vue-chartjs'],
},
},
},
// esbuild 配置用于移除 console
target: 'es2015',
},
esbuild: {
// 生产环境移除 console 和 debugger
drop: mode === 'production' ? ['console', 'debugger'] : [],
},
server: {
port: 5173,
proxy: {
// 只代理真正的 API 路径
// 注意:本地开发时后端默认运行在 8084 端口(见 src/config/settings.py
// 如果使用 Docker则通过 APP_PORT 环境变量映射(默认 80
'/api/': {
target: 'http://localhost:8084', // 本地开发端口
changeOrigin: true,
secure: false,
},
'/auth/': {
target: 'http://localhost:8084', // 本地开发端口
changeOrigin: true,
secure: false,
},
'/v1/': {
target: 'http://localhost:8084', // 本地开发端口
changeOrigin: true,
secure: false,
},
'/health': {
target: 'http://localhost:8084', // 本地开发端口
changeOrigin: true,
secure: false,
},
},
},
preview: {
port: 5173,
}
}))