lighthouse-lambda-node12
Run Google Chrome Lighthouse on AWS Lambda.
Installation
$ npm install lighthouse-lambda-node12 --save
Lambda function
// index.js const createLighthouse = exports { Promise // Handle other errors }
Testing locally
You can use docker-lambda to test your Lambda function locally.
$ docker run --rm -v "$PWD":/var/task lambci/lambda:nodejs12.x index.handler
Deployment
You can use docker-lambda to install dependencies and pack your Lambda function.
$ docker run --rm -v "$PWD":/var/task lambci/lambda:build-nodejs12.x bash -c "rm -rf node_modules && npm install" $ docker run --rm -v "$PWD":/var/task lambci/lambda:build-nodejs12.x bash -c "rm -f *.zip && zip lambda.zip -r node_modules index.js package.json"
- The file will be big (at least 75MB), so you need to upload it to S3 then deploy to Lambda from S3.
- You should allocate at least 512 MB memory and 15 seconds timeout to the function.
API
createLighthouse(url, [options], [config])
Same parameters as Using Lighthouse programmatically.
Returns a Promise
of an Object with the following fields:
chrome
: an instance ofchromeLauncher.launch()
, remember to callchrome.kill()
in the end.log
: an instance of lighthouse-logger (only if you setoptions.logLevel
).
Credits
- Version 5.6
lighthouse-lambda
uses Headless Chrome from chrome-aws-lambda. - Version 3
lighthouse-lambda
uses the Headless Chrome binary (stable version) from @serverless-chrome/lambda.