Integrations

CLI

Using the Unlighthouse CLI is the primary way to scan entire production sites.

Using the Unlighthouse CLI is the primary way to scan entire production sites.

Setup

npx unlighthouse --site <your-site>
# OR pnpm dlx unlighthouse --site <your-site>

Usage

Once installed globally you'll have access to Unlighthouse through the unlighthouse binary.

Do a the default scan.

unlighthouse --site example.com --debug

Run without caching, throttle the requests and do 3 samples.

unlighthouse --site example.com --debug --no-cache --throttle --samples 3

Configuration

Configuring the CLI can be done either through the CLI arguments or through a config file.

See the Configuration section for more details and the guides.

CLI Options

Options
-v, --versionDisplay version number.
--site <url>Host URL to scan.
--root <path>Define the project root.
--config-file <path>Path to config file.
--output-path <path>Path to save the contents of the client and reports to.
--cacheEnable the caching.
--no-cacheDisable the caching.
--desktopSimulate device as desktop.
--mobileSimulate device as mobile.
--throttleEnable the throttling.
--samplesSpecify the amount of samples to run.
--sitemapsComma separated list of sitemaps to use for scanning.
--urlsSpecify explicit relative paths as a comma-separated list.
e.g. unlighthouse --site unlighthouse.dev --urls /guide,/api,/config
--exclude-urlsSpecify relative paths (string or regex) to exclude from scanning as a comma-separated list.
e.g. unlighthouse --site unlighthouse.dev --exclude-urls /guide/.*,/api/.*
--include-urlsSpecify relative paths (string or regex) to include as a comma-separated list.
e.g. unlighthouse --site unlighthouse.dev --include-urls /guide/.*
--enable-javascriptWhen inspecting the HTML wait for the javascript to execute. Useful for SPAs.
--disable-javascriptWhen inspecting the HTML, don't wait for the javascript to execute.
--enable-i18n-pagesEnable scanning pages which use x-default.
--disable-i18n-pagesDisable scanning pages which use x-default.
--disable-dynamic-samplingDisable dynamic sampling of paths.
--extra-headersExtra headers to send with the requests.
--default-query-paramsDefault query params to send with the requests.
-d, --debugDebug. Enable debugging in the logger.
-h, --helpDisplay available CLI options

Config File

If you want to configure Unlighthouse, you can create a unlighthouse.config.ts file in your cwd.

export default {
  site: 'example.com',
  debug: true,
  scanner: {
    device: 'desktop'
  }
}