build: 前端改用 Bun + Vite,格式化改用 bun fmt

- 包管理和运行时换成 Bun:bun.lock 取代 package-lock.json,脚本用 bun --bun 运行,
  CI 改用 oven-sh/setup-bun(1.4.4,与后端镜像一致)
- 构建工具从 Rsbuild 换成 Vite 8,沿用 PUBLIC_ 环境变量前缀和 3000 端口;
  浏览器目标保持 Chrome 87 起(机房是 Chrome 105),用 plugin-legacy 按需注入
  core-js(toSorted 等),不生成旧浏览器的兼容包
- fmt 改用 Bun 自带的格式化,配置从 .prettierrc.toml 移到 bunfig.toml;
  prettier 包仍保留,编辑器里的「整理」按钮在浏览器里用它

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-26 19:10:50 +08:00
1 parent 351e4b9499
commit dde976cacb
13 files changed
+932 -3388

No files matched your search

+7 -5
View File
@@ -21,7 +21,8 @@ The backend was rewritten from Django in 2026-10 to cut memory use (~25 MB vs. 1
- `scripts/` — one-off CLIs: `migrate-from-postgres.ts`, `create-superuser.ts`, `classify-prompts.ts`, `recalculate-scores.ts`
- Roles: `super`, `admin`, `normal`. Task model is multi-table: `task_task` + one of `task_tutorial` / `task_challenge` / `task_creation` (`task_ptr_id`)
- **`client/`** — Vue 3 + TypeScript SPA built with **Rsbuild**
- **`client/`** — Vue 3 + TypeScript SPA built with **Vite**; Bun is the package manager and runtime (no Node/npm)
- `vite.config.ts` — browser targets are Chrome ≥ 87 (lab machines run Chrome 105); `@vitejs/plugin-legacy` only injects usage-based core-js polyfills, no legacy chunks
- UI framework: **Naive UI** (auto-imported via `unplugin-vue-components`)
- `src/api.ts` — Axios-based API client; 401 clears login and goes home, 403 alerts and goes home
- `src/router.ts` — Vue Router with auth guards
@@ -30,7 +31,7 @@ The backend was rewritten from Django in 2026-10 to cut memory use (~25 MB vs. 1
- **`Caddyfile`** — serves SPA from `build/` and `/media`, proxies `/api*` and `/ws*` to the backend
- **`docker-compose.yaml`** — `webpreview-web` (Caddy) and `webpreview-api` (Bun); `webpreview-db` (Postgres) exists only under the `migrate` profile for the one-time data migration
- **`.github/workflows/deploy.yaml`** — on push to `main`: build client, rsync to server `build/`, then `git pull && docker compose up -d --build` on the server
- **`.github/workflows/deploy.yaml`** — on push to `main`: build client with Bun, rsync to server `build/`, then `git pull && docker compose up -d --build` on the server
## Development Commands
@@ -51,9 +52,10 @@ Config comes from `server/.env` (see `server/.env.example`); dev DB is `server/d
### Client (from `client/`)
```bash
npm run start # Dev server (Rsbuild) on :3000
npm run build # Production build
npm run fmt # Format with Prettier
bun install # Install deps (bun.lock)
bun run start # Dev server (Vite, run on the Bun runtime) on :3000
bun run build # Production build (bun run build:staging for the school server)
bun fmt # Format with Bun's built-in formatter (config in bunfig.toml)
```
Frontend env vars used at build time: `PUBLIC_BASE_URL`, `PUBLIC_WS_URL`, `PUBLIC_WEB_URL` (dev proxy target for `/media` and `/ws`).