unLighthouse on GitHub Codespaces

Mountain/\AshMountain/\Ash
2 min read

What is unLighthouse?

https://unlighthouse.dev/

It's a open source project/tool by Harlan Wilton that can scan your entire site with Google Lighthouse and then output an easy to read HTML report of scan and the Core Web Vitals sores.

Screenshot of a report output by Unlighthouse

What is GitHub Codespaces?

https://github.com/codespaces

Codespaces is basically a Docker image on the fly for you to play in on the "cloud", with VScode as the UI. It's a VM (similar to Codesandbox, but already linked to your code on GitHub).

It's a terrific way to quickly play with code in a safe an temporary way. You can go to any project on GitHub and from the Code button start a new "Codespace" aka a Linux VM with the project's code already checked-out.

💡
I recommend using the ••• sub-menu to access the New with options... link and "beefing" up the Machine Type with some more RAM. The default minimum is too slow.

Showing the dialogue in for Codespaces within a project on GitHub

GitHub is very generous with this service and gives 120 "core hours" per month. Which on the smallest 2 core server is still about 2 hours a day - if you were to use it everyday. So a few hours every so often is perfect for a play around.

Run unLighthouse on GitHub Codespaces

The problem with VMs is they often restrict access to many services for security and performance reasons. One such service restriction that you'll hit when trying to run Unlighthouse is a suggestion to install Chromium using Snapd, which Codespaces doesn't allow. Here's a work-around I found reading through Puppeteer's documentation.

sudo apt-get update && sudo apt-get install -y wget gnupg && sudo wget -q -O - "https://dl-ssl.google.com/linux/linux_signing_key.pub" | sudo apt-key add - && sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && sudo apt-get update && sudo  apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 --no-install-recommends && sudo rm -rf /var/lib/apt/lists/*

The Chromium install commands are a cleanup of the Running Puppeteer in Docker install command.

Then you can run Unlighthouse with a command like:

PUPPETEER_SKIP_DOWNLOAD=true npx @unlighthouse/cli --site https://example.com/ --reporter jsonExpanded

See the Unlighthouse Documentation for more options.

0
Subscribe to my newsletter

Read articles from Mountain/\Ash directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mountain/\Ash
Mountain/\Ash