Skip to content

Commit c2523fe

Browse files
committed
Add lighthouse command
1 parent b47d030 commit c2523fe

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

Diff for: lighthouse-config.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const throttling = {
2+
disabled: {
3+
rttMs: 0,
4+
throughputKbps: 0,
5+
requestLatencyMs: 0,
6+
downloadThroughputKbps: 0,
7+
uploadThroughputKbps: 0,
8+
cpuSlowdownMultiplier: 0,
9+
}
10+
};
11+
12+
module.exports = {
13+
settings: {
14+
output: 'json',
15+
maxWaitForLoad: 45 * 1000,
16+
throttlingMethod: 'provided',
17+
throttling: throttling.disabled,
18+
auditMode: false,
19+
gatherMode: false,
20+
disableStorageReset: false,
21+
disableDeviceEmulation: true,
22+
emulatedFormFactor: 'none',
23+
blockedUrlPatterns: null,
24+
additionalTraceCategories: null,
25+
extraHeaders: null,
26+
onlyAudits: null,
27+
onlyCategories: null,
28+
skipAudits: null,
29+
},
30+
passes: [
31+
{
32+
passName: 'defaultPass',
33+
recordTrace: true,
34+
useThrottling: false,
35+
pauseAfterLoadMs: 1000,
36+
networkQuietThresholdMs: 1000,
37+
cpuQuietThresholdMs: 1000,
38+
gatherers: [],
39+
},
40+
],
41+
audits: [
42+
'time-to-first-byte',
43+
'metrics/first-meaningful-paint',
44+
'metrics/interactive',
45+
],
46+
};

Diff for: package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"karma-sourcemap-loader": "0.3.7",
5353
"karma-verbose-reporter": "0.0.6",
5454
"karma-webpack": "^2.0.4",
55+
"lighthouse": "^4.0.0-alpha.2-3.2.1",
5556
"load-grunt-config": "^0.19.2",
5657
"lodash-webpack-plugin": "^0.11.2",
5758
"npx": "^10.2.0",
@@ -62,7 +63,8 @@
6263
"webpack-merge": "^4.1.2"
6364
},
6465
"scripts": {
65-
"build": "webpack --config webpack.prod.js",
66-
"buildDev": "webpack --config webpack.dev.js"
66+
"build": "npx webpack --config webpack.prod.js",
67+
"buildDev": "npx webpack --config webpack.dev.js",
68+
"lighthouse": "npx lighthouse --config-path=lighthouse-config.js --quiet --output json --chrome-flags=\"--headless\" $URL | jq '.audits | map_values(.rawValue)'"
6769
}
6870
}

0 commit comments

Comments
 (0)