Skip to content

frontend: optimize build pipeline — turbo prune, route splitting, dev overlay #65

@BrewingCoder

Description

@BrewingCoder

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:

  1. pruner stage — runs turbo prune @holdfast-io/frontend --docker to output only the ~8 workspace packages the frontend needs
  2. builder stage — installs pruned deps, runs build:fast
  3. 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)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions