From c01a5e2ef53d05bb9e1faaea4fb9627ff35a33d1 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Jan 2026 10:23:42 +0100 Subject: [PATCH] ci(lighthouse): add local lighthouse audit --- .lighthouserc.cjs | 22 ++++++++++++++++++++++ local-lighthouse.sh | 14 ++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .lighthouserc.cjs create mode 100755 local-lighthouse.sh diff --git a/.lighthouserc.cjs b/.lighthouserc.cjs new file mode 100644 index 0000000..015a3fa --- /dev/null +++ b/.lighthouserc.cjs @@ -0,0 +1,22 @@ +module.exports = { + ci: { + collect: { + staticDistDir: '/app/dist', + settings: { + chromeFlags: '--no-sandbox --disable-setuid-sandbox --headless=new --disable-gpu --disable-dev-shm-usage', + }, + numberOfRuns: 1 + }, + assert: { + assertions: { + 'categories:performance': ['error', {minScore: 0.9}], + 'categories:accessibility': ['error', {minScore: 0.9}], + 'categories:best-practices': ['error', {minScore: 0.9}], + 'categories:seo': ['error', {minScore: 0.9}], + }, + }, + upload: { + target: 'temporary-public-storage', + }, + }, +}; \ No newline at end of file diff --git a/local-lighthouse.sh b/local-lighthouse.sh new file mode 100755 index 0000000..29b68df --- /dev/null +++ b/local-lighthouse.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +mkdir -p ./.lighthouseci + +docker run --rm \ +--user 0:0 \ +-v ./dist:/app/dist \ +-v ./.lighthouserc.cjs:/app/.lighthouserc.cjs \ +-v ./.lighthouseci:/app/.lighthouseci \ +-w /app \ +-e CHROME_PATH=/usr/bin/chromium-browser \ +zenika/alpine-chrome:with-node \ +npx @lhci/cli@0.15.x collect \ + --config=/app/.lighthouserc.cjs