Files
LokiStack/frontend/vite.config.ts
T
opsx 4f74fe6c3f
CI / Backend (go vet + test) (push) Canceled after 0s
CI / Frontend (lint + build + test) (push) Canceled after 0s
ci(engineering): Gitea Actions 门禁 + 前端测试设施 + 版本注入修复
- .gitea/workflows/ci.yml:后端 gofmt/vet/test + 前端 lint/test/build 双 job 门禁
- vitest + @testing-library + jsdom 落地,14 个命脉用例:useListQuery 乱序丢弃/卸载中止、
  http.ts 401 单飞刷新+队列重放+失败登出+silent 直拒、审计防抖、StepDeploy 部署目标、query-utils
- 版本注入断裂修复:main 补 buildTime/gitCommit 符号,build.sh/Dockerfile 注入 main.version,
  /health 返回真实版本,前端 package.json 版本对齐 2.0.0
- gofmt 清零(8 个存量未格式化文件)
2026-10-29 13:02:19 +08:00

65 lines
1.6 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 path from "path"
import { execSync } from "child_process"
import react from "@vitejs/plugin-react"
import { defineConfig } from "vitest/config"
import pkg from "./package.json" with { type: "json" }
// 构建指纹:版本来自 package.json,commit 用 git rev-parse 兜底(Settings「关于」展示)
function gitCommit(): string {
try {
return execSync("git rev-parse --short HEAD").toString().trim()
} catch {
return "unknown"
}
}
// https://vite.dev/config/
export default defineConfig({
test: {
environment: 'jsdom',
globals: true,
setupFiles: ['./src/test/setup.ts'],
include: ['src/**/*.test.{ts,tsx}'],
},
base: './',
plugins: [react()],
define: {
__APP_VERSION__: JSON.stringify(pkg.version),
__COMMIT_HASH__: JSON.stringify(gitCommit()),
},
server: {
port: 3000,
// 端口被占直接报错,不悄悄漂移到其他端口
strictPort: true,
proxy: {
'/api': {
target: 'http://localhost:8080',
changeOrigin: true,
},
},
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
build: {
rollupOptions: {
output: {
// 显式分包:框架与 UI 基础库独立成 chunk,页面懒加载 chunk 更小
manualChunks: {
'react-vendor': ['react', 'react-dom', 'react-router'],
'radix-vendor': [
'@radix-ui/react-dialog',
'@radix-ui/react-label',
'@radix-ui/react-select',
'@radix-ui/react-slot',
'@radix-ui/react-switch',
'@radix-ui/react-tabs',
],
},
},
},
},
})