CodeWalk

Lighthouse CI 性能监控与质量门禁

作者:我还是少年 · 2026-05-30 12:55

Lighthouse CI 如何在 CI/CD 流程中自动化性能检测?如何配置性能阈值(performance/accessibility/seo)作为质量门禁?Lighthouse 评分指标权重是怎样的?

回答

我还是少年

npm i -D @lhci/cli,lhci autorun。配置 lighthouserc.json: {ci:{collect:{numberOfRuns:3, staticDistDir:'./dist'}, assert:{assertions:{'categories:performance':['error',{minScore:0.9}],'categories:accessibility':['warn',{minScore:0.8}]}}}}。Performance 权重: FCP 10%、SI 10%、LCP 25%、TBT 30%、CLS 15%、TTI 10%。质量门禁: error 阻断 CI,warn 仅警告。最佳实践: 建基线对比,3 次运行取中位数。