Files
opsxsql/frontend/vite.config.ts
T
Logan.Li ac498c7ba2 refactor(frontend): split 7 oversized pages into feature co-location
Per guide ch.7 page split pattern (skeleton orchestrates, private
components live in features/<domain>/):
- InstancePage 1716->328, UsersPage 1309->240, TicketsPage 1076->195,
  TicketDetailPage 911->287, QueriesPage 883->479, LdapConfigPage 860->393,
  WorkflowPage 852->194
- new feature modules: datasource/ rbac/ ticket/ query/ system/ldap/
  governance/workflow/ (components + hooks + types + utils)
- stable keys replace index keys in dynamic lists; polling intervals
  and toast call sites preserved 1:1 (verified by agents)
- filter/pagination state moved to URL query via new useQueryState hook
  (Instance/Users/Tickets/AuditLogs pages): refresh/share/back-button
  restore state; composite updates applied atomically
- permission pure functions extracted to lib/permissions.ts (used by
  useAuth + useLogin); page-size audit: 0 pages over 700-line budget
2026-10-26 17:54:15 +08:00

49 lines
1.3 KiB
TypeScript

import { execSync } from "child_process"
import fs from "fs"
import path from "path"
import react from "@vitejs/plugin-react"
import { defineConfig } from "vite"
// 构建指纹:版本 + commit hash + 构建时间(设置页「关于」展示,排障救命)
const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, "package.json"), "utf-8"))
const gitHash = (() => {
try { return execSync("git rev-parse --short HEAD").toString().trim() } catch { return "unknown" }
})()
const buildTime = new Date().toISOString()
const APP_VERSION = `${pkg.version}+${gitHash} (${buildTime.slice(0, 16)})`
export default defineConfig({
base: '/',
define: {
__APP_VERSION__: JSON.stringify(APP_VERSION),
},
plugins: [react()],
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (!id.includes('node_modules')) return;
if (id.includes('react') || id.includes('react-router')) return 'vendor-react';
if (id.includes('@codemirror')) return 'vendor-editor';
if (id.includes('@radix-ui')) return 'vendor-ui';
},
},
},
},
server: {
port: 5173,
strictPort: true,
proxy: {
'/api': {
target: 'http://localhost:9000',
changeOrigin: true,
},
},
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
});