Repository navigation
Report frontend dist size and soft budget on every build - #2215
Conversation
Measure dist (total/HTML bytes, file and page counts, median page, top-level and reference/api directories) in every frontend build, write it to the job summary, and warn when it exceeds FRONTEND_DIST_BUDGET_BYTES (default 10 GiB). Set FRONTEND_DIST_BUDGET_MODE=error to fail instead. The file manifest and compression sample remain opt-in profiling diagnostics. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Frontend HTML artifact readyThe latest frontend build uploaded the This comment updates automatically when a new frontend build artifact is uploaded. |
Combined validation: real
|
| Before | After all four PRs | |
|---|---|---|
Ev2ServiceArtifactsRoot/Images/aspiredev.tar.gz |
~4 GB | 1.76 GB |
| Built HTML pages | 38,344 | 29,134 |
Site output (dist) |
9.8 GB | 3.73 GB |
wwwroot in image |
n/a | 3.73 GB originals + 0.68 GB .br |
The container starts in 11 s, /healthz returns 200, and idle memory is about 2 GB, likely from the 134 MB staticwebassets.endpoints.json.
Testing against the container
- Layout check: 35 representative layouts (docs, splash, hub, 404,
/de/fallback,/ja/translated, C#/TS/Go API landing, package, type and member pages) on desktop and mobile. Every page returned the expected status, with no failed requests and no page errors. - Full Playwright suite,
CI=1 bunx playwright test, all 3 projects, reusing the container on :4322: 1,632 passed, 5 failed, 2 flaky, 107 skipped. Failures are triaged below. - Manual testing of the running container found no issues.
This PR: on its own it doesn't change the size; it adds the per-build size report. The 9.8 GB to 3.73 GB dist drop above is what this report will show in CI once the others merge.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the frontend build-size reporting and configurable budget changes.
No open issues 🎉
What changed in this PR
Adds frontend build-size reporting and a configurable budget to track progress toward smaller container images and flag output-size regressions.
Changes:
- Reports total and HTML sizes, file counts, median HTML page size, and directory breakdowns in the job summary.
- Runs measurement whenever build output is available, with a default 10 GiB warning budget and optional failure mode controlled by repository variables.
- Keeps file manifests and compression samples profiling-only, and adds tests for reporting, budget behavior, and workflow configuration.
| File | Description |
|---|---|
src/frontend/tests/unit/build-performance.vitest.test.ts |
Adds coverage for size reports, budget defaults and enforcement, and measurement-step configuration. |
src/frontend/scripts/measure-build-output.mjs |
Adds concurrent measurement, detailed summaries, and configurable budget checks. |
.github/workflows/frontend-build.yml |
Enables measurement when output exists and passes repository budget settings. |
Review effort: Balanced
Summary
Part of a series to cut the size of the frontend container image (StaticHost +
dist, currently ~9.8 GB ofdist). Sibling PRs: dropping English fallback copies in locale folders, slimming the C# API reference sidebar, and moving repeated inline SVG/script/CSS to shared assets. This PR adds the guardrail that tracks progress and catches regressions.src/frontend/scripts/measure-build-output.mjsreference/apisizes by language.profile_buildruns..github/workflows/frontend-build.yml: "Measure frontend output" now runs on every build wheredist/index.htmlexists, not only forprofile_buildruns.::warningannotation. The default is 10 GiB, just above the current baseline, so it doesn't fire yet.FRONTEND_DIST_BUDGET_BYTESoverrides the default.FRONTEND_DIST_BUDGET_MODE=errorturns the warning into a build failure.always().Third-party links and affiliations
None
Validation
vitest run tests/unit/build-performance.vitest.test.ts(standalone vitest 4.1.11, because bun isn't installed locally): passed, 11/11 tests (3 new, 1 updated).node scripts/measure-build-output.mjsagainst a fakedistwith 80,007 files: passed. It measured them in ~1.9 s, exited 0 in the default mode, printed a::warningand exited 0 withDIST_SIZE_BUDGET_BYTES=1000, and printed a::errorand exited 1 withDIST_SIZE_BUDGET_MODE=error.bun run buildwas not run locally; CI will produce the first real numbers.