Files
gaokao-volunteer-system/apps/web/vite.config.ts

71 lines
2.0 KiB
TypeScript
Raw Normal View History

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tailwindcss from '@tailwindcss/vite';
import path from 'node:path';
// V10 选项 B · Vite 5 + React 19 + Tailwind 4
// 替代 Next.js 16 App Router使用 React Router 7 (client-side routing)
export default defineConfig({
plugins: [react(), tailwindcss()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
server: {
host: '0.0.0.0',
port: 3000,
strictPort: true,
// CloudStudio / WorkBuddy 预览代理白名单
allowedHosts: [
'webview.e2b.bj5.sandbox.cloudstudio.club',
'.sandbox.cloudstudio.club',
'.cloudstudio.club',
'.workbuddy.agentos-worker.net',
'.agentos-worker.net',
'localhost',
'127.0.0.1',
],
},
preview: {
host: '0.0.0.0',
port: 4173,
strictPort: true,
},
build: {
target: 'es2022',
sourcemap: true,
rollupOptions: {
output: {
// V10 优化: 手动 chunk split
manualChunks: {
'react-vendor': ['react', 'react-dom', 'react-router-dom', 'react-router'],
'query-vendor': ['@tanstack/react-query', '@tanstack/react-query-devtools'],
'state-vendor': ['zustand'],
'form-vendor': ['react-hook-form', '@hookform/resolvers', 'zod'],
'markdown-vendor': ['react-markdown', 'rehype-sanitize', 'remark-gfm'],
feat(sprint-3): 5 个新模块(Share/Query/Review/LLM/Poster)+ G2 闸门通过 ## 5 大新模块(30+ hooks + 5 页面 + 1 LLM 适配器) ### Share Link (T-B-22/28) - useShareLinkCreate/Delete/LatestQuery/StatsQuery - ShareDialog 弹窗(QR + 链接 + 复制) - StatsCard 3 卡(访问数/独立访客/最近访问) - AccessTrendChart(recharts 折线图) ### Data Query (T-B-23) - useScoreLineQuery / useRankEstimatorQuery / useMajorsQuery / useSchoolsQuery - DataQueryPage:4 过滤器 + 等效分数 + 分数线表 ### Review Flow (T-B-24) - useReviewStartMutation / useReviewStatusQuery / useReviewActionMutation - Zod discriminated union 处理 3 种 action - 5 状态轮询(pending/in_progress/approved/rejected/changes_requested) - ReviewPage:状态机 UI + 3 操作按钮 ### Portal (T-B-25) - usePortalCWBQuery / usePortalFullPlanQuery - PortalPage:token 路由 + 等效分数 + 完整方案 ### Poster (T-B-27) - usePosterGenerateMutation(3 模板 classic/modern/minimal) - PosterPreviewPage:渐变预览 + 下载 + 复制 QR ### LLM (T-B-17/26) - 4 模适配器(claude/gpt/gemini/deepseek) - enhanceWithFallback 链式降级 - useLLMConfig / useAuditEnhanceMutation ## G2 闸门(全部通过) - typecheck: 0 error - lint: 0 error 0 warning - test (Vitest): 37/37 passed (10 文件) - test:e2e (Playwright): 24/24 passed (4 浏览器 × 6 spec) - build (Vite): 312 KB gzip (recharts 拆分后主 chunk 83KB) - codegen:check: 0 any ## 关键技术决策 1. 4 模 LLM fallback 链:claude → gpt → gemini → deepseek 2. 所有 API 强类型 + Zod 校验(apiClient 强制 schema) 3. recharts 拆 manualChunk:chart-vendor 104KB gzip 4. Portal token 路由:/portal/:token 共享 token 自动级联 ## Sprint 3 收口报告 SPRINT_3_CLOSEOUT_2026-07-03.md 下一步:Sprint 4 · 性能 + 监控(Sentry / Web Vitals)
2026-07-03 16:42:03 +08:00
'chart-vendor': ['recharts'],
'qrcode-vendor': ['qrcode.react'],
'icons-vendor': ['lucide-react'],
},
chunkFileNames: 'assets/[name]-[hash].js',
entryFileNames: 'assets/[name]-[hash].js',
assetFileNames: 'assets/[name]-[hash][extname]',
},
},
// 4KB 以下内联
assetsInlineLimit: 4096,
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./src/test/setup.ts'],
css: false,
coverage: {
provider: 'v8',
reporter: ['text', 'html', 'json'],
exclude: ['**/node_modules/**', '**/dist/**', '**/*.test.{ts,tsx}', '**/*.spec.{ts,tsx}'],
},
},
});