Dentolize · Sandbox Build Optimizations Walkthrough

Glossary

CRA (Create React App) — The build tooling clinic-web is based on. Provides a preconfigured webpack setup so the project doesn't hand-maintain its own from scratch.

CRACO — "Create React App Configuration Override." A layer that lets a CRA project reach into and modify CRA's normally-hidden webpack configuration without "ejecting" (permanently exposing and forking the whole config). This PR's entire change lives in clinic-web's CRACO config file, packages/clinic-web/craco.config.js.

webpack — The bundler that turns clinic-web's source files into the JavaScript, CSS, and asset files actually served to a browser. Most terms below are webpack concepts this PR configures.

Terser — The JavaScript minifier webpack uses in production builds, run via TerserPlugin. Shrinks bundle size by renaming variables, removing whitespace, and similar transforms. Can run its work across multiple parallel worker processes, controlled by its parallel option.

ForkTsCheckerWebpackPlugin — A webpack plugin that runs a full TypeScript type-check in a separate ("forked") process during the build, so type errors can fail the build. Skipped entirely for sandbox builds by this PR.

webpack cache (type: 'memory' vs type: 'filesystem') — Webpack can cache intermediate build work to speed up subsequent builds. The in-memory default only lives as long as the build process itself (so it never helps across separate build invocations); type: 'filesystem' persists that cache to disk at a given cacheDirectory, so a later, separate build process can reuse it if the underlying directory still exists.

BuildKit cache mount — A Docker BuildKit feature (--mount=type=cache,...) that lets a RUN step in a Dockerfile read and write a directory that persists across separate docker build invocations, even though each build otherwise starts from a clean container filesystem. This is what makes the filesystem webpack cache in this PR actually durable between sandbox builds — see Dockerfile:298-299.

SANDBOX_BUILD — The environment variable that gates every change in this PR. Set to the string 'true' only by the sandbox overlay Dockerfile (Dockerfile:156). Never set by any production release build script, so all three optimizations are inert in production.

Sandbox build / sandbox preview — The internal system that builds a disposable, per-branch deployment of Dentolize (web app + API + supporting services) so engineers can preview or demo a branch before it merges. Not something clinic or patient users ever interact with directly. This PR is entirely about making that system's builds faster and lighter on memory.

isProduction — A local variable in craco.config.js, true when webpack's mode is 'production' (i.e., a real build, as opposed to the start dev server). One of the two conditions (alongside SANDBOX_BUILD === 'true') gating this PR's optimizations.