Skip to content

Instantly share code, notes, and snippets.

@peterjaap
Last active December 15, 2020 09:26
Show Gist options
  • Save peterjaap/83f990257f3638d4dcd2ddc43363aa01 to your computer and use it in GitHub Desktop.
Save peterjaap/83f990257f3638d4dcd2ddc43363aa01 to your computer and use it in GitHub Desktop.
Run Lighthouse locally

Run Lighthouse locally

You only need Docker installed. Add to ~/.zshrc, or ~/.bashrc, or whatever you're using;

lh() {
  mkdir -p lighthouse && \
  docker run --rm -it -v "$PWD":/usr/src -w /usr/src markhobson/node-chrome /bin/bash -c "npm i -g lighthouse && lighthouse --enable-error-reporting --chrome-flags=\"--headless --no-sandbox\" $1 --output html --output-path ./lighthouse/index.html" && \
  open lighthouse/index.html
}

Restart terminal (or source ~/.zshrc) and use with lh https://yoururltotest.com/whatever

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment