Files
Aether/frontend/vite.config.ts
fawney19 21eedbe331 feat: add version management with setuptools-scm
- Configure hatch-vcs for automatic version generation from git tags
- Update pyproject.toml to use dynamic versioning
- Add src/_version.py for runtime version access
- Update src/__init__.py to import version from _version
- Add __APP_VERSION__ to frontend vite config
- Add version script to frontend package.json
- Update CI workflows to trigger on version tags instead of branches
2025-12-14 00:12:37 +08:00

84 lines
2.2 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'
import { execSync } from 'child_process'
function getGitVersion(): string {
try {
return execSync('git describe --tags --always').toString().trim()
} catch {
return '0.0.0.dev0'
}
}
// https://vite.dev/config/
export default defineConfig(({ mode }) => ({
// GitHub Pages 部署时使用仓库名作为 base
base: process.env.GITHUB_PAGES === 'true' ? '/Aether/' : '/',
plugins: [vue()],
define: {
__APP_VERSION__: JSON.stringify(getGitVersion()),
},
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,
}
}))