Replaces the placeholder with the page from the design and the texts from the live site: Andrea's introduction with her portrait, how it started, two photos, life outside photography and a booking button. The page is now indexed, with its own title, description, preview image and AboutPage data about Andrea. The portrait loads straight away instead of after the page, since on phones it is the largest paint. Lighthouse no longer lets every indexed page use the homepage's lower mobile performance target; it now only applies to the homepage itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
116 lines
4.3 KiB
JavaScript
116 lines
4.3 KiB
JavaScript
// Lighthouse CI tegen de gebouwde site (`pnpm preview`), zodat de echte
|
|
// securityheaders en de SPA-fallback 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.
|
|
|
|
const origin = 'http://localhost:4173';
|
|
|
|
// Moet gelijk lopen met src/sitePages.ts (een test bewaakt dat)
|
|
const indexedPaths = ['/', '/over-mij'];
|
|
const noindexPaths = [
|
|
'/portfolio',
|
|
'/soorten-fotoshoots',
|
|
'/contact',
|
|
'/privacyverklaring',
|
|
];
|
|
const notFoundPath = '/bestaat-niet';
|
|
|
|
// 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;
|
|
|
|
// 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.
|
|
const performanceLevel =
|
|
process.env.LIGHTHOUSE_PERFORMANCE === 'warn' ? 'warn' : 'error';
|
|
|
|
const quality = {
|
|
'categories:performance': [performanceLevel, { minScore: 0.9 }],
|
|
'categories:accessibility': ['error', { minScore: 1 }],
|
|
'categories:best-practices': ['error', { minScore: 1 }],
|
|
};
|
|
|
|
// SEO-audits die ook voor noindex-pagina's moeten slagen. Alleen
|
|
// `is-crawlable` mag falen: die pagina's staan bewust op noindex.
|
|
const seoBasics = {
|
|
'document-title': 'error',
|
|
'link-text': 'error',
|
|
'crawlable-anchors': 'error',
|
|
'image-alt': 'error',
|
|
};
|
|
|
|
const escape = (path) => path.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&');
|
|
const exact = (paths) => `^${origin}(${paths.map(escape).join('|')})$`;
|
|
|
|
module.exports = {
|
|
performanceLevel,
|
|
indexedPaths,
|
|
noindexPaths,
|
|
notFoundPath,
|
|
ci: {
|
|
collect: {
|
|
startServerCommand: 'pnpm preview --port 4173 --strictPort',
|
|
startServerReadyPattern: 'Local',
|
|
url: [...indexedPaths, ...noindexPaths, notFoundPath].map(
|
|
(path) => origin + path,
|
|
),
|
|
numberOfRuns: 1,
|
|
// In de CI-container draait Chrome als root en heeft het
|
|
// --no-sandbox nodig (LIGHTHOUSE_CHROME_FLAGS in de workflow).
|
|
// Niet via LHCI_COLLECT__SETTINGS__*: dat vervangt alle settings,
|
|
// ook de desktop-preset.
|
|
settings: {
|
|
chromeFlags: process.env.LIGHTHOUSE_CHROME_FLAGS ?? '',
|
|
},
|
|
},
|
|
assert: {
|
|
// Home first: lighthouserc.desktop.cjs raises its performance
|
|
// target back to 0.9. Every URL matching an entry must pass it,
|
|
// so the home exception may only match the home page itself.
|
|
assertMatrix: [
|
|
{
|
|
matchingUrlPattern: exact(['/']),
|
|
assertions: {
|
|
...quality,
|
|
'categories:performance': [
|
|
performanceLevel,
|
|
{ minScore: homeMobilePerformance },
|
|
],
|
|
'categories:seo': ['error', { minScore: 1 }],
|
|
},
|
|
},
|
|
{
|
|
matchingUrlPattern: exact(
|
|
indexedPaths.filter((path) => path !== '/'),
|
|
),
|
|
assertions: {
|
|
...quality,
|
|
'categories:seo': ['error', { minScore: 1 }],
|
|
},
|
|
},
|
|
{
|
|
matchingUrlPattern: exact(noindexPaths),
|
|
assertions: {
|
|
...quality,
|
|
...seoBasics,
|
|
'meta-description': 'error',
|
|
canonical: 'error',
|
|
},
|
|
},
|
|
{
|
|
matchingUrlPattern: exact([notFoundPath]),
|
|
assertions: { ...quality, ...seoBasics },
|
|
},
|
|
],
|
|
},
|
|
upload: {
|
|
// HTML- en JSON-rapporten per meting; in CI als download bij de run
|
|
target: 'filesystem',
|
|
outputDir: 'lighthouse-reports/mobile',
|
|
},
|
|
},
|
|
};
|