serverless-lighthouse-lk
v1.0.2
Published
Preconfigured package for running lighthouse in a serverless function
Downloads
3
Maintainers
Readme
Serverless Lighthouse Package
A package with all the required dependencies to run Google Lighthouse in a lambda function created through the Serverless framework.
It took me entirely too long to get Chrome, AWS Lambda, and Lighthouse to play nicely together. This package hopes to alleviate you of that misery.
Installation
npm install --save serverless-lighthouse-lk
Usage
In your Lambda function code:
//Traditional node require
const lighthouse = require('serverless-lighthouse-lk');
//ES6 import
import lighthouse from 'serverless-lighthouse-lk';
const results = await lighthouse.runLighthouse(targetUrl);
You can optionally pass in flags to customize the run.
await lighthouse.runLighthouse(targetUrl, chromeFlags, lighthouseFlags, lighthouseConfig)
Default values will be used for optional arguments when they are not provided. These defaults can be accessed through the below functions. If you choose to pass in your own set of flags, I recommend adding them to the defaults provided.
Note: It is NOT recommended to modify the port
property in the lighthouseFlags
.
const lighthouse = require('serverless-lighthouse-lk');
const chromeFlags = lighthouse.defaultChromeFlags;
const lighthouseFlags = lighthouse.defaultLighthouseFlags;
The default lighthouseConfig
(below) is barebones and can be modified as needed.
{
extends: 'lighthouse:default'
}