-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlighthouserc.js
More file actions
311 lines (259 loc) · 9.05 KB
/
Copy pathlighthouserc.js
File metadata and controls
311 lines (259 loc) · 9.05 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
/**
* Lighthouse CI Configuration
*
* This configuration defines performance budgets and collection settings
* for Lighthouse CI audits.
*
* ## Performance Targets
* - Performance Score: > 90
* - Accessibility Score: > 95
* - Best Practices Score: > 95
* - PWA Score: > 95
*
* ## Timing Budgets
* - Time to First Byte: < 500ms
* - First Contentful Paint: < 1.5s
* - Largest Contentful Paint: < 2.5s
* - Time to Interactive: < 3s
* - Cumulative Layout Shift: < 0.1
*
* ## Size Budgets
* - Total Transfer: < 600KB
* - JavaScript: < 500KB
* - CSS: < 50KB
*
* @see https://github.com/GoogleChrome/lighthouse-ci/blob/main/docs/configuration.md
*/
module.exports = {
ci: {
// ========================================================================
// Collection Settings
// ========================================================================
collect: {
// Serve the built application from dist/
staticDistDir: './dist',
// Number of runs per URL (more runs = more reliable results)
numberOfRuns: 3,
// URLs to audit
url: [
'http://localhost/', // Main app
],
// Chrome flags for consistent testing
settings: {
// Simulate mobile device (Moto G4)
preset: 'desktop',
// Throttling settings
throttlingMethod: 'simulate',
throttling: {
rttMs: 150,
throughputKbps: 1638.4,
cpuSlowdownMultiplier: 4,
},
// Only run specific categories
onlyCategories: [
'performance',
'accessibility',
'best-practices',
'seo',
'pwa',
],
// Skip audits that are noisy or not relevant
skipAudits: [
'uses-http2', // Not relevant for local testing
'redirects-http', // Not relevant for local testing
],
// Form factor
formFactor: 'desktop',
// Screen emulation
screenEmulation: {
mobile: false,
width: 1920,
height: 1080,
deviceScaleFactor: 1,
disabled: false,
},
// Wait for page to be fully loaded
maxWaitForFcp: 15000,
maxWaitForLoad: 35000,
},
// Chrome launch settings
chromeFlags: [
'--no-sandbox',
'--disable-gpu',
'--disable-dev-shm-usage',
'--disable-extensions',
'--disable-background-networking',
'--disable-default-apps',
'--disable-sync',
'--disable-translate',
'--mute-audio',
'--no-first-run',
'--safebrowsing-disable-auto-update',
],
},
// ========================================================================
// Assertion Settings (Performance Budgets)
// ========================================================================
assert: {
// Preset for PWA assertions
preset: 'lighthouse:recommended',
assertions: {
// =====================================================================
// Category Score Assertions
// =====================================================================
// Performance: Must score at least 90
'categories:performance': ['error', { minScore: 0.9 }],
// Accessibility: Must score at least 95
'categories:accessibility': ['error', { minScore: 0.95 }],
// Best Practices: Must score at least 95
'categories:best-practices': ['error', { minScore: 0.95 }],
// SEO: Must score at least 90
'categories:seo': ['warn', { minScore: 0.9 }],
// PWA: Must score at least 95
'categories:pwa': ['error', { minScore: 0.95 }],
// =====================================================================
// Performance Metrics Assertions
// =====================================================================
// First Contentful Paint: < 1.5s (1500ms)
'first-contentful-paint': ['error', { maxNumericValue: 1500 }],
// Largest Contentful Paint: < 2.5s (2500ms)
'largest-contentful-paint': ['error', { maxNumericValue: 2500 }],
// Time to Interactive: < 3s (3000ms)
interactive: ['error', { maxNumericValue: 3000 }],
// Speed Index: < 3s (3000ms)
'speed-index': ['warn', { maxNumericValue: 3000 }],
// Total Blocking Time: < 300ms
'total-blocking-time': ['error', { maxNumericValue: 300 }],
// Cumulative Layout Shift: < 0.1
'cumulative-layout-shift': ['error', { maxNumericValue: 0.1 }],
// Server Response Time (TTFB): < 500ms
'server-response-time': ['error', { maxNumericValue: 500 }],
// =====================================================================
// Resource Budgets
// =====================================================================
// Total byte weight: < 600KB (614400 bytes)
'total-byte-weight': ['error', { maxNumericValue: 614400 }],
// JavaScript execution time: < 2s
'bootup-time': ['warn', { maxNumericValue: 2000 }],
// Main thread work: < 3s
'mainthread-work-breakdown': ['warn', { maxNumericValue: 3000 }],
// =====================================================================
// Accessibility Assertions
// =====================================================================
// All accessibility audits should pass
'color-contrast': 'error',
'image-alt': 'error',
'label': 'error',
'button-name': 'error',
'link-name': 'error',
'document-title': 'error',
'html-has-lang': 'error',
'meta-viewport': 'error',
// =====================================================================
// Best Practices Assertions
// =====================================================================
// HTTPS
'is-on-https': 'off', // Off for local testing
// No deprecated APIs
'deprecations': 'error',
// No errors in console
'errors-in-console': 'warn',
// No vulnerable libraries
'no-vulnerable-libraries': 'error',
// =====================================================================
// PWA Assertions
// =====================================================================
// Service worker registration
'service-worker': 'error',
// Installable
'installable-manifest': 'error',
// Splash screen
'splash-screen': 'error',
// Theme color
'themed-omnibox': 'warn',
// Viewport
'viewport': 'error',
// =====================================================================
// SEO Assertions
// =====================================================================
// Meta description
'meta-description': 'warn',
// Crawlable links
'crawlable-anchors': 'warn',
// Mobile friendly
'font-size': 'warn',
'tap-targets': 'warn',
},
// Budget for resource sizes (bytes)
budgets: [
{
path: '/*',
resourceSizes: [
{
resourceType: 'total',
budget: 600, // 600KB
},
{
resourceType: 'script',
budget: 500, // 500KB
},
{
resourceType: 'stylesheet',
budget: 50, // 50KB
},
{
resourceType: 'image',
budget: 100, // 100KB
},
{
resourceType: 'font',
budget: 100, // 100KB
},
{
resourceType: 'document',
budget: 50, // 50KB HTML
},
],
resourceCounts: [
{
resourceType: 'total',
budget: 30, // Max 30 requests
},
{
resourceType: 'script',
budget: 10, // Max 10 JS files
},
{
resourceType: 'stylesheet',
budget: 5, // Max 5 CSS files
},
],
},
],
},
// ========================================================================
// Upload Settings
// ========================================================================
upload: {
// Use temporary public storage (free)
target: 'temporary-public-storage',
// Or use your own LHCI server:
// target: 'lhci',
// serverBaseUrl: 'https://your-lhci-server.com',
// token: process.env.LHCI_TOKEN,
// Or upload to GitHub:
// target: 'filesystem',
// outputDir: './.lighthouseci',
},
// ========================================================================
// Server Settings (for self-hosted LHCI)
// ========================================================================
// server: {
// storage: {
// storageMethod: 'sql',
// sqlDialect: 'sqlite',
// sqlDatabasePath: './.lighthouseci/db.sql',
// },
// },
},
};