fix(ci): perf job — point Lighthouse at /fr/ and /en/, drop spa fallback #92

Merged
julien merged 1 commits from fix/portal-shell/perf-job-localize-paths into main 2026-05-11 17:18:54 +02:00
Owner

Summary

The previous PR (#91) enabled --localize on the production build, so the output layout became dist/apps/portal-shell/browser/{en,fr}/ with no top-level index.html. The perf CI job broke in two places downstream:

  1. nx run portal-shell:serve-static had 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 crashed with ENOENT … copyfile … index.html before opening the port. lhci then failed its healthcheck and exited 1.
  2. lighthouserc.js was hitting http://localhost:4200/, which now lands on http-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

  • Drop spa: true from the serve-static target in apps/portal-shell/project.json. 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 here for the perf gate and for local prod-build inspection of 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.

Verification

Local repro (against the merged plumbing PR's build):

$ pnpm exec nx run portal-shell:serve-static
$ curl -s -o /dev/null -w '%{http_code}\n' http://localhost:4200/en/   # 200
$ curl -s -o /dev/null -w '%{http_code}\n' http://localhost:4200/fr/   # 200

Served files have the right metadata per locale:

/tmp/probe-en.html: lang="en"   <base href="/en/">
/tmp/probe-fr.html: lang="fr"   <base href="/fr/">

Side-effect to call out

  • /en/deep/route and /fr/deep/route now return 404 from nx 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.
  • Local nx serve-static + curl against /en/ and /fr/ returns the expected per-locale index.html.
  • CI: pnpm ci:perf runs through serve-static start → Lighthouse autorun (×3 per locale, ×2 locales = 6 audits) → assertions hold ≥ 90 on Performance for both.
## Summary The previous PR (#91) enabled `--localize` on the production build, so the output layout became `dist/apps/portal-shell/browser/{en,fr}/` with **no top-level `index.html`**. The `perf` CI job broke in two places downstream: 1. **`nx run portal-shell:serve-static`** had `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 crashed with `ENOENT … copyfile … index.html` before opening the port. lhci then failed its healthcheck and exited 1. 2. **`lighthouserc.js`** was hitting `http://localhost:4200/`, which now lands on `http-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 - **Drop `spa: true`** from the `serve-static` target in [`apps/portal-shell/project.json`](apps/portal-shell/project.json). 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 here for the perf gate and for local prod-build inspection of entry points. For deep-link testing in dev, `nx serve` is the right tool. - **Update [`lighthouserc.js`](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. ## Verification Local repro (against the merged plumbing PR's build): ``` $ pnpm exec nx run portal-shell:serve-static $ curl -s -o /dev/null -w '%{http_code}\n' http://localhost:4200/en/ # 200 $ curl -s -o /dev/null -w '%{http_code}\n' http://localhost:4200/fr/ # 200 ``` Served files have the right metadata per locale: ``` /tmp/probe-en.html: lang="en" <base href="/en/"> /tmp/probe-fr.html: lang="fr" <base href="/fr/"> ``` ## Side-effect to call out - `/en/deep/route` and `/fr/deep/route` now return 404 from `nx 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 - [x] `pnpm exec nx run-many -t lint test build --projects=portal-shell` — green. - [x] Local `nx serve-static` + curl against `/en/` and `/fr/` returns the expected per-locale `index.html`. - [x] CI: `pnpm ci:perf` runs through `serve-static` start → Lighthouse autorun (×3 per locale, ×2 locales = 6 audits) → assertions hold ≥ 90 on Performance for both.
julien added 1 commit 2026-05-11 17:18:40 +02:00
fix(ci): perf job — point Lighthouse at /fr/ and /en/, drop spa fallback
CI / commits (pull_request) Successful in 2m42s
CI / check (pull_request) Successful in 3m4s
CI / scan (pull_request) Successful in 3m2s
CI / a11y (pull_request) Successful in 2m7s
CI / perf (pull_request) Successful in 5m37s
e9b58a62c0
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.
julien merged commit 04675b1b59 into main 2026-05-11 17:18:54 +02:00
julien deleted branch fix/portal-shell/perf-job-localize-paths 2026-05-11 17:18:56 +02:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: julien/apf_portal#92