AgentEvalTool/frontend/web/vite.config.ts
sinohqb 12c1732617 v0.4-t3t4: OpenClaw 通道 + 前端 bundle 优化
## T3: OpenClaw 直连通道
- channels/openclaw.py: OpenClawChannel
  - send: POST /api/v1/chat/completions
  - poll_reply: GET /api/v1/chat/completions/{msg_id}
  - health_check: GET /api/health
  - 默认从 settings 读取 upstream/auth_token,channel_config 可覆盖
- channels/factory.py: 注册 ChannelType.OPENCLAW → OpenClawChannel
- Targets.tsx: 通道类型下拉新增「HTTP 通用」和「OpenClaw」选项
- 8 个 OpenClawChannel 单元测试(发送/轮询/超时/健康检查/默认配置)

## T4: 前端 Bundle 优化
- App.tsx: 7 个页面改为 React.lazy 懒加载 + Suspense fallback(Spin)
- vite.config.ts: 精细化 manualChunks
  - vendor-antd / vendor-monaco / vendor-charts 独立拆分
  - 主 index 68KB → 7KB,页面按需加载
  - 无循环依赖警告

## 测试
- 178/178 全绿,覆盖率维持 77%

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-17 15:37:14 +08:00

48 lines
1.2 KiB
TypeScript

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
server: {
port: 3000,
proxy: {
'/api': {
target: 'http://localhost:8000',
changeOrigin: true,
},
'/ws': {
target: 'ws://localhost:8000',
ws: true,
},
'/openclaw': {
target: 'http://localhost:8000',
changeOrigin: true,
ws: true,
},
},
},
build: {
rollupOptions: {
output: {
manualChunks(id) {
// Monaco Editor — only used by Scenarios page
if (id.includes('@monaco-editor') || id.includes('monaco-editor')) {
return 'vendor-monaco'
}
// @ant-design/charts — only used by Home page
if (id.includes('@ant-design/charts')) {
return 'vendor-charts'
}
// Ant Design core — used everywhere
if (id.includes('antd') || id.includes('@ant-design/icons')) {
return 'vendor-antd'
}
// React + remaining libs — used everywhere, merged to avoid circular imports
if (id.includes('node_modules')) {
return 'vendor'
}
},
},
},
},
})