Sign inSign up

sqerison/lighthouse-audit

By sqerison

•Updated almost 2 years ago

This project automates Lighthouse audits for both mobile and desktop platforms using Puppeteer.

Image
Languages & frameworks
0

990

sqerison/lighthouse-audit repository overview

⁠Lighthouse Audit with Puppeteer

This project automates Lighthouse audits for both mobile and desktop platforms using Puppeteer. It supports optional authentication, dynamic platform selection, and configurable report formats. The reports are stored in a reports directory, which is mounted as a Docker volume.

⁠WARNING: docker doesn't work on the Apple Silicon processors. Please run using node.js directly.

⁠Features

  • Run Lighthouse audits for mobile, desktop, or both platforms.
  • Optional login support using credentials.
  • Customizable Lighthouse categories for audits.
  • Configurable report formats: HTML (default), JSON, or CSV.
  • Saves reports in a mounted reports folder.

⁠Prerequisites

⁠Installation

  1. Clone the repository:

    git clone https://github.com/your-username/lighthouse-audit.git
    cd lighthouse-audit
    
  2. Build the Docker image:

    docker build -t sqerison/lighthouse-audit .
    

⁠Usage

⁠Run Without Authentication

To run the audit without login credentials:

docker run --rm \
  -v $(pwd)/reports:/usr/src/app/reports \
  -e SITE_URL="https://google.com" \
  sqerison/lighthouse-audit
⁠Run With Authentication

To run the audit with login credentials:

docker run --rm \
  -v $(pwd)/reports:/usr/src/app/reports \
  -e SITE_URL="https://google.com" \
  -e USERNAME="your-username" \
  -e PASSWORD="your-password" \
  -e USERNAME_FIELD="input[name='login']" \
  -e PASSWORD_FIELD="input[name='password']" \
  -e SUBMIT_BUTTON="input[name='submit']" \
  sqerison/lighthouse-audit
⁠Run for Specific Platforms

By default, the audit runs for both mobile and desktop. To specify a platform:

  • Desktop only:

    docker run --rm \
      -v $(pwd)/reports:/usr/src/app/reports \
      -e SITE_URL="https://example.com"  \
      -e PLATFORM="desktop" \
      sqerison/lighthouse-audit
    
  • Mobile only:

    docker run --rm \
      -v $(pwd)/reports:/usr/src/app/reports \
      -e SITE_URL="https://example.com" \
      -e PLATFORM="mobile" \
      sqerison/lighthouse-audit
    
⁠Run With Custom Categories

To customize Lighthouse categories, use the CATEGORIES environment variable:

docker run --rm \
  -v $(pwd)/reports:/usr/src/app/reports \
  -e SITE_URL="https://example.com" \
  -e CATEGORIES="performance,accessibility" \
  sqerison/lighthouse-audit
⁠Generate Reports in Specific Formats

The default report format is html. Other types could be specified as: html, json, csv. To specify a different format:

  • JSON Report:
    docker run --rm \
      -v $(pwd)/reports:/usr/src/app/reports \
    -e SITE_URL="https://example.com" \
    -e REPORT_TYPE="json" \
    sqerison/lighthouse-audit
    

⁠Configuration

⁠Environment Variables
VariableDefault ValueDescription
SITE_URLhttps://google.comURL to audit (login or main page).
USERNAMENoneUsername for login (optional).
PASSWORDNonePassword for login (optional).
USERNAME_FIELDinput[name='login']Selector for the username field.
PASSWORD_FIELDinput[name='password']Selector for the password field.
SUBMIT_BUTTONinput[name='submit']Selector for the login button.
CATEGORIESAll categoriesComma-separated list of categories to audit.
PLATFORMbothPlatform to audit: mobile, desktop, or both.
REPORT_TYPEhtmlReport format: html, json, or csv.
REPORT_DIR./reportsDirectory to save the Lighthouse report.
⁠Lighthouse Categories
  • performance: Page load speed and efficiency.
  • accessibility: Compliance with web accessibility best practices.
  • best-practices: Web development best practices.
  • seo: Search engine optimization.
  • pwa: Progressive Web App standards.

⁠Output

Reports are saved in the reports folder with filenames based on the platform and format:

  • lighthouse-report-desktop.html
  • lighthouse-report-mobile.html
  • lighthouse-report-desktop.json
  • lighthouse-report-mobile.csv (Depending on the REPORT_TYPE specified.)

Ensure the reports folder is mounted as a Docker volume for easy access.

⁠License

This project is licensed under the MIT License.

⁠Contact

For inquiries or issues, please contact [email protected]⁠ or open an issue in the repository.

Tag summary

Content type

Image

Digest

sha256:972ee7263…

Size

287.1 MB

Last updated

almost 2 years ago

docker pull sqerison/lighthouse-audit