ant audits
CLI tool and lib to gather app audits via Lighthouse. IN BETA.
Based on the code in pwmetrics, this repository removes features such as Upload / Command Line Chart.
Thanks in addition to pwmetrics for additional work on the lighthouse basis: stripping out the perf test section separately; supporting flexible customization of audit metrics; and a single command to run multiple times.
此仓库在 pwmetrics 的代码基础上,去掉了“上传”/"命令行图表"等功能。
另外感谢 pwmetrics 在 lighthouse 的基础上额外做出的这些工作:单独剥离出了 perf 测试部分;支持灵活的定制 audit 指标;一个命令可以运行多次。
$ npm i
Added umi-perf
view
Use like this:
const getHtml = require('anta/recipes/umi-perf/scripts/getHtml.js');
const html = getHtml(reportData);
`[
{
entryURL: 'index.html',
success: true,
resultUrl: 'xx.json',
resultJson: { "runs": [ {},{},... ] },
},
{
entryURL: 'index1.html',
success: true,
resultUrl: 'xx.json',
resultJson: { "runs": [ {},{},... ] },
}
]`
CLI Usage
$ anta <url> <flags>
$ anta --help
anta https://mobile.ant.design/kitchen-sink/
anta https://mobile.ant.design/kitchen-sink/ --runs=3
anta https://mobile.ant.design/kitchen-sink/ --json
anta https://mobile.ant.design/kitchen-sink/ --json --output-path='./lh-report.json'
anta --config=anta-config.js
anta --expectations
All available configuration options
anta --config
package.json
...
"anta": {
"url": "http://example.com/",
// other configuration options
"expectations": {
...
}
}
...
anta-config.js
module.exports = {
url: 'http://example.com/',
flags: {
runs: '3',
expectations: true
chromePath: '/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'
chromeFlags: []
},
expectations: {
ttfcp: {
warn: '>=1500',
error: '>=2000'
},
ttfmp: {
warn: '>=2000',
error: '>=3000'
},
fv: {
...
},
psi: {
...
},
vc85: {
...
},
vs100: {
...
},
ttfi: {
...
},
ttci: {
...
}
}
}
anta --expectations --config=anta-config.js
Available metrics:
-
ttfcp
- First Contentful Paint
-
ttfmp
- First Meaningful Paint
-
psi
- Perceptual Speed Index
-
fv
- First Visual Change
-
vc
- Visually Complete 100%
-
ttfi
- First Interactive (vBeta)
-
ttci
- Time to Consistently Interactive (vBeta)
-
vc85
- Visually Complete 85%
-
dom-size
- dom size
Read article Performance metrics. What’s this all about? or 前端感官性能的衡量和优化实践 which is decoding this metrics.
API
const Metrics = require('anta');
const options = {
flags: {
runs: '3',
expectations: true
chromeFlags: [
'--headless'
]
}
};
const pwMetrics = new Metrics('http://example.com/', options);
pwMetrics.start();
Recipes