build size reduse it
This commit is contained in:
28
AGENTS.md
28
AGENTS.md
@@ -83,6 +83,34 @@ Gray is the accent. The **only** colour permitted is semantic: success, warning,
|
||||
- `StyleOverrides` supports structural pseudo-classes, not just interaction ones —
|
||||
`':first-child'` emits correctly (used for the table first-column lead-in).
|
||||
|
||||
## Deployment — never ship `.next/` wholesale
|
||||
This filled the production disk and took the server down once. A working tree's `.next/`
|
||||
reaches **2+ GB**, but almost none of it is runtime state:
|
||||
|
||||
| path | size (typical) | ships? |
|
||||
|---|---|---|
|
||||
| `.next/dev` | 1.8 GB | **no** — Turbopack dev-server cache from `npm run dev` |
|
||||
| `.next/cache` | 120–160 MB | **no** — incremental build cache, build host only |
|
||||
| `.next/server`, `types`, `trace` | ~24 MB | **no** — inputs to the standalone trace, not read at runtime |
|
||||
| `.next/standalone` | 54 MB | **yes** — server.js + traced node_modules |
|
||||
| `.next/static` | 3 MB | **yes** — hashed client assets (nginx serves at `/_next/static/`) |
|
||||
| `public` | 344 KB | **yes** |
|
||||
|
||||
Those last three are the entire payload: **~55 MB unpacked, 18 MB gzipped.**
|
||||
- Non-Docker deploy: `npm run bundle` → `dist/loyaly-mer-login.tar.gz`. Never `scp -r .next`.
|
||||
- Docker: `.dockerignore` excludes `node_modules` and `.next`. **Do not delete it** — without
|
||||
it `COPY . .` pushes the host's 2 GB `.next` and 639 MB `node_modules` into the build
|
||||
context, including darwin-arm64 sharp binaries that are wrong for Alpine.
|
||||
- `npm run clean` drops `.next`, `dist` and the tsbuildinfo when the tree gets heavy.
|
||||
|
||||
**`CI_BUILD=1` in container builds.** Next 16.3 enables `turbopackFileSystemCacheForBuild`
|
||||
by default; it writes 117 MB to `.next/cache` that only pays off when that directory is
|
||||
restored between builds. Docker/Dokploy starts from a clean layer every time, so it is
|
||||
written and never read. The Dockerfile sets `CI_BUILD=1`, which flips the flag off in
|
||||
`next.config.ts`: **~20% less build CPU** (32s vs 40–43s measured) and `.next` drops
|
||||
202 MB → 86 MB. Leave it unset locally — repeat `npm run build` there does reuse the cache.
|
||||
It changes no output: the deployable payload is 58 MB either way.
|
||||
|
||||
## Conventions
|
||||
- Follow the Astryx rules above: no raw `<div>` for layout, no hardcoded hex/px, component
|
||||
props first then token-backed Tailwind utilities.
|
||||
|
||||
Reference in New Issue
Block a user