-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunlighthouse.config.ts
76 lines (72 loc) · 2.33 KB
/
unlighthouse.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { defineConfig } from '@unlighthouse/core';
import type { UserConfig } from '@unlighthouse/core';
/**
* Performance budget thresholds by environment.
* Scores range from 0-100, with higher scores being better.
* @see https://web.dev/performance-scoring/
*/
const budgets = {
development: {
performance: 80, // Relaxed for local dev
accessibility: 95, // Keep high a11y standards
'best-practices': 90, // Maintain good practices
seo: 90, // Strong SEO baseline
},
production: {
performance: 90, // High perf in prod
accessibility: 100, // Perfect a11y required
'best-practices': 95, // Strict practices
seo: 95, // Excellent SEO
},
} as const;
/**
* Core application routes to test.
* Add routes that represent unique page types/templates.
*/
const routes = [
'/',
'/healthcheck', // Monitor application health
'/robots.txt', // Search engine crawling rules
'/sitemap.xml', // Site structure for crawlers
] as string[];
const isDev = process.env.NODE_ENV === 'development';
const isCI = Boolean(process.env.CI);
const budget = isCI
? {
...budgets.production,
accessibility: 80, // GitHub Actions reporting unexpected score
seo: 60, // Added robots.txt file without Sitemap and arrived here
}
: isDev
? budgets.development
: budgets.production;
export default defineConfig({
site: 'http://127.0.0.1:8787',
urls: routes,
scanner: {
device: 'desktop', // Desktop metrics for CI and dev
throttle: !isCI, // No throttle in CI
customSampling: {}, // URL pattern matching
ignoreI18nPages: true, // Skip i18n variants
maxRoutes: 200, // Route scan limit
skipJavascript: false, // Run page scripts
dynamicSampling: 5, // Sample dynamic routes
sitemap: false, // Ignore sitemap.xml
robotsTxt: false, // Ignore robots.txt
crawler: false, // Don't crawl for URLs
samples: isDev ? 1 : 5, // More prod samples
exclude: ['/private/*'], // Skip private routes
},
lighthouseOptions: {
throttlingMethod: 'devtools',
onlyCategories: ['performance', 'accessibility', 'best-practices', 'seo'],
},
ci: {
budget,
buildStatic: false, // Exclude HTML reports
reporter: 'jsonSimple', // Simple JSON output
},
puppeteerClusterOptions: {
maxConcurrency: isCI ? 1 : undefined, // Single worker in CI
},
} satisfies UserConfig);