-
Notifications
You must be signed in to change notification settings - Fork 13
/
lighthouserc.cjs
71 lines (62 loc) · 1.91 KB
/
lighthouserc.cjs
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
const glob = require('glob');
const path = require('path');
let extraCollect = {};
// If URLs aren't being specified on the command line, start the documentation
// website locally and run Lighthouse against all pages. Determine the list of
// URLs by finding all HTML files in the output documentation directory;
// this requires that the docs have already been built before this code is run.
const urlsSpecified = process.argv.some((arg) =>
arg.match(/^--(collect\.)?url=/),
);
if (!urlsSpecified) {
const filenames = glob.sync('**/*.html', {
cwd: path.join(__dirname, 'docs/_site/design-system'),
ignore: 'admin/**',
nonull: false,
});
if (!filenames.length) {
// eslint-disable-next-line no-console
console.error(
"No HTML files found; build the docs first with 'yarn build-decap'.",
);
process.exit(1);
}
extraCollect = {
// Serve the documentation site locally when Lighthouse runs. Serve the
// already-built HTML files using the Node http-server package, which
// defaults to port 8080 and is simpler and reliably faster than using the
// Jekyll server.
startServerCommand: 'yarn serve-html',
startServerReadyPattern: 'Hit CTRL-C to stop the server',
// Run Lighthouse against every URL in the local site.
url: filenames
.map((filename) =>
filename
.replace(/index.html$/, '')
.replace(/.html$/, '')
.replace(/^/, 'http://localhost:8080/design-system/'),
)
.sort(),
};
}
module.exports = {
ci: {
collect: {
numberOfRuns: 1,
settings: {
formFactor: 'desktop',
screenEmulation: { mobile: false },
onlyCategories: 'accessibility',
},
...extraCollect,
},
assert: {
assertions: {
'categories:accessibility': ['error', { minScore: 1 }],
},
},
upload: {
target: 'temporary-public-storage',
},
},
};