<aside> 💡 목차
</aside>
pnpm add @lhci/cli --save-dev
.lighthouserc.cjs
생성// .lighthouserc.cjs
module.exports = {
ci: {
collect: {
staticDistDir: './dist',
url: ['<http://localhost:3000>'],
numberOfRuns: 5,
},
upload: {
target: 'temporary-public-storage',
},
},
};
왜 cjs 확장자를 사용했는가?
collect.staticDistDir
:
collect.url
Lighthouse CI가 내부적으로 서버를 실행할 때, 사용자가 url에 입력한 포트 번호(3000)를 사용합니다.
http://localhost:3000에 접속해서 성능을 측정합니다.
여러 페이지를 측정하고 싶다면 배열에 URL을 추가할 수 있습니다:
url: [
'<http://localhost:3000>',
'<http://localhost:3000/about>',
'<http://localhost:3000/contact>'
]
collect.numberOfRuns
upload.target
temporary-public-storage
: Lighthouse CI가 제공하는 무료 임시 저장소, 누구나 접근 가능, 약 7일 동안 결과를 보관CLI에서 직접 실행할 때:
lhci autorun
npx
를 사용해야 로컬/전역/임시 설치를 모두 확인할 수 있습니다package.json의 scripts를 통해 실행할 때
{
"scripts": {
"lighthouse": "lhci autorun"
}
}
node_modules/.bin
디렉토리를 추가node_modules/.bin
디렉토리를 먼저 검색npx
없이도 로컬 패키지를 실행할 수 있습니다.