fix(ci): perf job — point Lighthouse at /fr/ and /en/, drop spa fallback (#92)
## 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`. - [ ] 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. --------- Co-authored-by: Julien Gautier <julien.gautier@apf.asso.fr> Reviewed-on: #92
This commit was merged in pull request #92.
This commit is contained in:
+10
-7
@@ -4,20 +4,23 @@
|
||||
* Thresholds match the Google "Good" Core Web Vitals values plus the
|
||||
* Lighthouse Performance score floor we set as the project bar.
|
||||
*
|
||||
* Critical-routes list grows as features land. v1 only checks the
|
||||
* static-served portal-shell bundle (which today shows the Nx Welcome
|
||||
* placeholder); meaningful per-route assertions land alongside the
|
||||
* features that introduce those routes.
|
||||
* Critical-routes list grows as features land. v1 checks the
|
||||
* static-served portal-shell bundle on both locale entry points
|
||||
* (`/fr/` is the default served at the production root via the smart
|
||||
* redirect; `/en/` is the alternate). ADR-0019 mandates that both
|
||||
* locales clear the same bar. Per-route assertions land alongside
|
||||
* the features that introduce those routes.
|
||||
*/
|
||||
module.exports = {
|
||||
ci: {
|
||||
collect: {
|
||||
// Serve the production bundle statically (no BFF needed for v1
|
||||
// measurements). When real auth / routes exist, the URL list
|
||||
// expands to the critical-routes list documented in ADR-0017.
|
||||
// measurements). With `--localize` the build emits per-locale
|
||||
// folders (`browser/en/`, `browser/fr/`); we serve their parent
|
||||
// and Lighthouse hits each locale's root index.html directly.
|
||||
startServerCommand: 'pnpm nx run portal-shell:serve-static',
|
||||
startServerReadyPattern: 'Available on:',
|
||||
url: ['http://localhost:4200/'],
|
||||
url: ['http://localhost:4200/fr/', 'http://localhost:4200/en/'],
|
||||
numberOfRuns: 3,
|
||||
settings: {
|
||||
// Slow-4G profile so scores are stable across CI runners and
|
||||
|
||||
Reference in New Issue
Block a user