bha*_*nsa 10 google-chrome lighthouse gulp
我正在使用gulp进行项目,我在这个gulp任务中添加了灯塔:
gulp.task("lighthouse", function(){
return launchChromeAndRunLighthouse('http://localhost:3800', flags, perfConfig).then(results => {
console.log(results);
});
});
Run Code Online (Sandbox Code Playgroud)
这是我的launchChromeAndRunLighthouse()函数
function launchChromeAndRunLighthouse(url, flags = {}, config = null) {
return chromeLauncher.launch().then(chrome => {
flags.port = chrome.port;
return lighthouse(url, flags, config).then(results =>
chrome.kill().then(() => results));
});
}
Run Code Online (Sandbox Code Playgroud)
它在命令行中为我提供了json输出.我可以在这里发布我的json 并获得报告.
有什么办法可以使用gulp生成HTML报告吗?
如果您认为这个问题对未来的读者有帮助,欢迎您开始赏金.
我也遇到过这个问题。我在 github issues 的某个地方发现你不能以编程方式使用 html 选项,但 Lighthouse 确实公开了报告生成器,因此你可以围绕它编写简单的文件写入和打开函数以获得相同的效果。
const ReportGenerator = require('../node_modules/lighthouse/lighthouse-core/report/v2/report-generator.js');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1342 次 |
| 最近记录: |