Adds the URL rules to the preview server, IIS config and deploy

The preview server and web.config now follow the same URLs as nginx, without
the SPA fallback. Lighthouse exceptions need a recorded reason and the 404 page
is audited through an opt-in route. The deploy checks the build first and the
served result afterwards. The IIS rules stay unverified until a host exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-01 18:13:21 +01:00
co-authored by Claude Opus 5.5
parent 716692825e
commit e4e7f8c82c
17 changed files with 1919 additions and 220 deletions
+82 -62
View File
@@ -1,5 +1,5 @@
// Lighthouse CI tegen de gebouwde site (`pnpm preview`), zodat de echte
// securityheaders en de SPA-fallback meetellen. Doelen: NFR-P-01, NFR-A-01,
// securityheaders en de 404-afhandeling meetellen. Doelen: NFR-P-01, NFR-A-01,
// NFR-S-01/02. Dit is de mobiele meting; lighthouserc.desktop.cjs bouwt hierop
// voort voor desktop. `pnpm lighthouse` draait beide.
@@ -19,35 +19,62 @@ const indexedPaths = [
'/contact',
];
const noindexPaths = ['/privacyverklaring'];
const notFoundPath = '/404.html';
// Homepage mobiel voorlopig 0,8: de foto's zijn nog niet responsive en de
// titel verschijnt pas na de JavaScript. Komt terug op 0,9 met responsive
// afbeeldingen uit de API/CMS en prerendering (NFR-P-01).
const homeMobilePerformance = 0.8;
// Lighthouse refuses a main document with an error status, so the preview
// serves the 404 page with status 200 on this route only, and only when it is
// started with --audit-route (BR-HST-22). /404.html itself is a real 404.
const notFoundPath = '/__audit/404';
// Indexed content pages whose largest paint is a photo, mobile 0.85 for now.
// Lighthouse simulates a slow connection: the photo is only requested once
// the main bundle and the page's own chunk have run, so these pages land on
// LCP ~3.2s and a score of ~0.895, right on 0.9 (measured on /over-mij and
// /soorten-fotoshoots; fewer image bytes do not move it). The shoot pages
// (largest paint: the first story photo) are in the same position. Back to
// 0.9 with prerendering or a smaller main bundle (NFR-P-01).
const photoPagePaths = [
'/over-mij',
'/soorten-fotoshoots',
'/soorten-fotoshoots/newborn',
'/soorten-fotoshoots/zwangerschap',
'/soorten-fotoshoots/gezin',
'/soorten-fotoshoots/loveshoot',
'/soorten-fotoshoots/portret',
];
const photoPageMobilePerformance = 0.85;
// Mobile performance exceptions, keyed by path. Every entry needs a recorded
// decision and a floor below 0.9 (BR-HST-23); a page without an entry must
// reach 0.9. These are the temporary exceptions carried over from the
// frontend-shell feature, until the final measurement of prerendering:
// - the homepage (0.8): the photos are not responsive yet and the title only
// appears after the JavaScript (NFR-P-01).
// - the indexed content pages whose largest paint is a photo (0.85):
// Lighthouse simulates a slow connection and the photo is only requested
// once the main bundle and the page's own chunk have run, so they land on
// LCP ~3.2s and a score of ~0.895, right on 0.9 (measured on /over-mij and
// /soorten-fotoshoots; fewer image bytes do not move it). The shoot pages
// (largest paint: the first story photo) are in the same position.
const temporary = 'tijdelijk, tot de eindmeting van prerendering';
const mobileExceptions = {
'/': { minScore: 0.8, decision: temporary },
'/over-mij': { minScore: 0.85, decision: temporary },
'/soorten-fotoshoots': { minScore: 0.85, decision: temporary },
'/soorten-fotoshoots/newborn': { minScore: 0.85, decision: temporary },
'/soorten-fotoshoots/zwangerschap': { minScore: 0.85, decision: temporary },
'/soorten-fotoshoots/gezin': { minScore: 0.85, decision: temporary },
'/soorten-fotoshoots/loveshoot': { minScore: 0.85, decision: temporary },
'/soorten-fotoshoots/portret': { minScore: 0.85, decision: temporary },
};
// The exceptions of the content pages with a photo as largest paint
const photoPagePaths = Object.keys(mobileExceptions).filter(
(path) => path !== '/',
);
const validateExceptions = (exceptions, paths) => {
for (const [path, { minScore, decision }] of Object.entries(exceptions)) {
if (!paths.includes(path)) {
throw new Error(`Exception for unknown page ${path}`);
}
if (typeof decision !== 'string' || decision.trim() === '') {
throw new Error(`Exception for ${path} has no decision`);
}
if (!(minScore < 0.9)) {
throw new Error(`Exception for ${path} is not below 0.9`);
}
}
};
validateExceptions(mobileExceptions, indexedPaths);
// Performance hangt af van de snelheid van de meetmachine: Lighthouse vertraagt
// de CPU 4x ten opzichte van een snelle desktop. Op de CI-runner (Raspberry Pi)
// valt de score daardoor 30-40 punten lager uit dan op een pc. In CI daarom
// alleen melden (LIGHTHOUSE_PERFORMANCE=warn); lokaal in `pnpm check` blokkerend.
// numberOfRuns is bewust 1: een pagina die precies op 0,90 zit kan `pnpm check`
// toevallig laten falen.
const performanceLevel =
process.env.LIGHTHOUSE_PERFORMANCE === 'warn' ? 'warn' : 'error';
@@ -69,10 +96,32 @@ const seoBasics = {
const escape = (path) => path.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&');
const exact = (paths) => `^${origin}(${paths.map(escape).join('|')})$`;
// Indexed pages without a mobile exception
const otherIndexedPaths = indexedPaths.filter(
(path) => path !== '/' && !photoPagePaths.includes(path),
);
// One entry per page with an exception, one for all other indexed pages
const buildIndexedEntries = (exceptions, paths) => {
const others = paths.filter((path) => !(path in exceptions));
return [
...Object.entries(exceptions).map(([path, { minScore }]) => ({
matchingUrlPattern: exact([path]),
assertions: {
...quality,
'categories:performance': [performanceLevel, { minScore }],
'categories:seo': ['error', { minScore: 1 }],
},
})),
// Empty until another indexed page without an exception exists
...(others.length > 0
? [
{
matchingUrlPattern: exact(others),
assertions: {
...quality,
'categories:seo': ['error', { minScore: 1 }],
},
},
]
: []),
];
};
module.exports = {
performanceLevel,
@@ -80,9 +129,13 @@ module.exports = {
noindexPaths,
notFoundPath,
photoPagePaths,
mobileExceptions,
validateExceptions,
buildIndexedEntries,
ci: {
collect: {
startServerCommand: 'pnpm preview --port 4173 --strictPort',
startServerCommand:
'pnpm preview --port 4173 --strictPort --audit-route',
startServerReadyPattern: 'Local',
url: [...indexedPaths, ...noindexPaths, notFoundPath].map(
(path) => origin + path,
@@ -101,40 +154,7 @@ module.exports = {
// to 0.9. Every URL matching an entry must pass it, so an
// exception may only match the pages it names.
assertMatrix: [
{
matchingUrlPattern: exact(['/']),
assertions: {
...quality,
'categories:performance': [
performanceLevel,
{ minScore: homeMobilePerformance },
],
'categories:seo': ['error', { minScore: 1 }],
},
},
{
matchingUrlPattern: exact(photoPagePaths),
assertions: {
...quality,
'categories:performance': [
performanceLevel,
{ minScore: photoPageMobilePerformance },
],
'categories:seo': ['error', { minScore: 1 }],
},
},
// Empty until another indexed page without an exception exists
...(otherIndexedPaths.length > 0
? [
{
matchingUrlPattern: exact(otherIndexedPaths),
assertions: {
...quality,
'categories:seo': ['error', { minScore: 1 }],
},
},
]
: []),
...buildIndexedEntries(mobileExceptions, indexedPaths),
{
matchingUrlPattern: exact(noindexPaths),
assertions: {