feat: unlighthouse configuration and dependencies

This commit is contained in:
Bart van der Braak 2024-02-18 22:21:07 +01:00
parent 5aa27c86a5
commit ab161e0b91
5 changed files with 3034 additions and 10 deletions

View file

@ -75,13 +75,17 @@ jobs:
- name: Install Dependencies - name: Install Dependencies
run: pnpm install -g @unlighthouse/cli puppeteer run: pnpm install -g @unlighthouse/cli puppeteer
- name: Run Unlighthouse - name: Run Unlighthouse
run: | run: |
unlighthouse-ci \ export SCAN_URL=${{ github.ref == 'refs/heads/main' && env.WEBSITE_URL || steps.vercel_preview_url.outputs.preview_url }}
--site "${{ github.ref == 'refs/heads/main' && env.WEBSITE_URL || steps.vercel_preview_url.outputs.preview_url }}" \ export AUTH_COOKIE=$(curl '$SCAN_URL/auth?/login' \
--reporter jsonExpanded \ -H 'Origin: $SCAN_URL' \
--build-static -F "email=test_user" \
-F "password=${{ secrets.TEST_USER_PASSWORD }}" \
--verbose 2>&1 | awk -F'pb_auth=' '/pb_auth/{print $2;exit}' | awk -F';' '{print $1}')
unlighthouse-ci
- name: Upload report to Cloudflare pages - name: Upload report to Cloudflare pages
uses: cloudflare/wrangler-action@v3.4.1 uses: cloudflare/wrangler-action@v3.4.1

1
.gitignore vendored
View file

@ -8,3 +8,4 @@ node_modules
!.env.example !.env.example
vite.config.js.timestamp-* vite.config.js.timestamp-*
vite.config.ts.timestamp-* vite.config.ts.timestamp-*
.unlighthouse

View file

@ -33,6 +33,7 @@
"tailwindcss": "^3.3.6", "tailwindcss": "^3.3.6",
"tslib": "^2.4.1", "tslib": "^2.4.1",
"typescript": "^5.0.0", "typescript": "^5.0.0",
"unlighthouse": "^0.10.6",
"vite": "^5.0.3", "vite": "^5.0.3",
"zod": "^3.22.4" "zod": "^3.22.4"
}, },

File diff suppressed because it is too large Load diff

23
unlighthouse.config.ts Normal file
View file

@ -0,0 +1,23 @@
import { defineConfig } from 'unlighthouse'
export default defineConfig ({
site: process.env.SITE_URL || 'http://localhost:5173/',
scanner: {
samples: 1,
throttle: true,
},
cookies: [
{
name: 'pb_auth',
value: process.env.AUTH_COOKIE || '',
domain: 'localhost',
path: '/',
sameSite: 'Lax',
}
],
ci: {
reporter: 'jsonExpanded',
buildStatic: true,
budget: 65,
},
});