fix(ci): perf job — point Lighthouse at /fr/ and /en/, drop spa fallback #92
Reference in New Issue
Block a user
Delete Branch "fix/portal-shell/perf-job-localize-paths"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The previous PR (#91) enabled
--localizeon the production build, so the output layout becamedist/apps/portal-shell/browser/{en,fr}/with no top-levelindex.html. TheperfCI job broke in two places downstream:nx run portal-shell:serve-statichadspa: true. The@nx/web:file-serverexecutor reads that as "copy<staticFilePath>/index.htmlto404.htmlfor SPA fallback". The source file no longer exists, so the executor crashed withENOENT … copyfile … index.htmlbefore opening the port. lhci then failed its healthcheck and exited 1.lighthouserc.jswas hittinghttp://localhost:4200/, which now lands onhttp-server's directory listing (no index.html at that path). Even if the server had started, the audit would have measured the wrong page.What changes
spa: truefrom theserve-statictarget inapps/portal-shell/project.json. Deep-link fallback in production is the reverse proxy's job (it routes/{en,fr}/anythingto the matchingindex.html);nx serve-staticis only used here for the perf gate and for local prod-build inspection of entry points. For deep-link testing in dev,nx serveis the right tool.lighthouserc.jsurllist to['http://localhost:4200/fr/', 'http://localhost:4200/en/'], matching the directive in ADR-0019 that both locales clear the same performance bar.Verification
Local repro (against the merged plumbing PR's build):
Served files have the right metadata per locale:
Side-effect to call out
/en/deep/routeand/fr/deep/routenow return 404 fromnx serve-static. That's by design — Lighthouse only audits the root locale URLs, and the reverse proxy owns deep-link routing in production.http://localhost:4200/returns http-server's directory listing under the new layout. Lighthouse doesn't hit it, so the perf gate is unaffected. We could disable the listing if it becomes a footgun.Test plan
pnpm exec nx run-many -t lint test build --projects=portal-shell— green.nx serve-static+ curl against/en/and/fr/returns the expected per-localeindex.html.pnpm ci:perfruns throughserve-staticstart → Lighthouse autorun (×3 per locale, ×2 locales = 6 audits) → assertions hold ≥ 90 on Performance for both.The previous PR enabled `--localize` on the production build, so the output structure became `dist/apps/portal-shell/browser/{en,fr}/` with no top-level `index.html`. Two CI breakages followed: - `nx run portal-shell:serve-static` (lhci's `startServerCommand`) was configured with `spa: true`. The `@nx/web:file-server` executor reads that as "copy `<staticFilePath>/index.html` to `404.html` for SPA fallback". The source file no longer exists, so the executor crashes with `ENOENT … copyfile … index.html` and never opens the port. - Even if the server had started, `lighthouserc.js` was targeting `http://localhost:4200/` which produces an `http-server` directory listing under the new layout. Lighthouse would have run against that, not the SPA. Fixes: - Drop `spa: true` from the `serve-static` target. The executor no longer attempts the missing copy. Deep-link fallback in production is the reverse proxy's job (it routes `/{en,fr}/anything` to the matching `index.html`); `nx serve-static` is only used for the perf gate and for local prod-build inspection of the entry points. For deep-link testing in dev, `nx serve` is the right tool. - Update `lighthouserc.js` `url` list to `['http://localhost:4200/fr/', 'http://localhost:4200/en/']`, matching the directive in ADR-0019 that both locales clear the same performance bar.