Problem
- Docker frontend build takes ~10 minutes for a one-line change
- Local
yarn dev Vite startup takes ~3 minutes
- Root causes: entire 50+ package monorepo copied into Docker for yarn install, no route-based code splitting, no dep pre-bundling, tsc runs before every build
Plan
Step 1 — build:fast script
Add build:fast to src/frontend/package.json that skips tsc -noEmit. Used for dev builds and Docker; existing build script (with type check) stays for CI.
Step 2 — Vite optimizeDeps tuning
Add optimizeDeps.include in vite.config.ts for antd, apollo, recharts, framer-motion, firebase, codemirror, etc. Forces pre-bundling on first startup instead of on-demand.
Step 3 — Route-based code splitting
Convert all 9 eagerly-imported core routes in ApplicationRouter.tsx to React.lazy. Wrap in <Suspense>. Reduces initial bundle and Vite processing time.
Step 4 — Vanilla-extract: skip
136 .css.ts files across both frontend and packages/ui — migration not worth the churn.
Step 5 — turbo prune Dockerfile
Rewrite frontend.Dockerfile as 3-stage build:
pruner stage — runs turbo prune @holdfast-io/frontend --docker to output only the ~8 workspace packages the frontend needs
builder stage — installs pruned deps, runs build:fast
frontend-prod stage — nginx runtime (unchanged)
Step 6 — Dev compose overlay
New infra/docker/compose.dev-frontend.yml — mounts src/frontend/build directly into nginx container. One-line change deploys in ~5 seconds instead of 10 minutes.
Expected Impact
| Change |
Docker build |
Local dev |
| build:fast |
-30-60s |
— |
| optimizeDeps |
— |
-30-60s |
| Route splitting |
— |
-60-90s |
| turbo prune |
-3-5 min |
— |
| Dev compose overlay |
eliminates rebuild |
— |
| Total |
~10 min → ~3 min |
~3 min → ~60s |
Files to modify
src/frontend/package.json
src/frontend/vite.config.ts
src/frontend/src/routers/ProjectRouter/ApplicationRouter.tsx
infra/docker/frontend.Dockerfile
infra/docker/compose.dev-frontend.yml (new)
Problem
yarn devVite startup takes ~3 minutesPlan
Step 1 —
build:fastscriptAdd
build:fasttosrc/frontend/package.jsonthat skipstsc -noEmit. Used for dev builds and Docker; existingbuildscript (with type check) stays for CI.Step 2 — Vite
optimizeDepstuningAdd
optimizeDeps.includeinvite.config.tsfor antd, apollo, recharts, framer-motion, firebase, codemirror, etc. Forces pre-bundling on first startup instead of on-demand.Step 3 — Route-based code splitting
Convert all 9 eagerly-imported core routes in
ApplicationRouter.tsxtoReact.lazy. Wrap in<Suspense>. Reduces initial bundle and Vite processing time.Step 4 — Vanilla-extract: skip
136
.css.tsfiles across both frontend and packages/ui — migration not worth the churn.Step 5 —
turbo pruneDockerfileRewrite
frontend.Dockerfileas 3-stage build:prunerstage — runsturbo prune @holdfast-io/frontend --dockerto output only the ~8 workspace packages the frontend needsbuilderstage — installs pruned deps, runsbuild:fastfrontend-prodstage — nginx runtime (unchanged)Step 6 — Dev compose overlay
New
infra/docker/compose.dev-frontend.yml— mountssrc/frontend/builddirectly into nginx container. One-line change deploys in ~5 seconds instead of 10 minutes.Expected Impact
Files to modify
src/frontend/package.jsonsrc/frontend/vite.config.tssrc/frontend/src/routers/ProjectRouter/ApplicationRouter.tsxinfra/docker/frontend.Dockerfileinfra/docker/compose.dev-frontend.yml(new)