Running the tests from the Audits tab is nice and easy, but how can we ensure that the quality of our application is maintained before we push it live?
The answer is to incorporate Lighthouse into our deploy process, and use it to assess our build automatically. This is similar to having a test suite run when we hit yarn deploy. Fortunately, Google supplies with a Lighthouse CLI for exactly this purpose.
Let’s install it with the following:
yarn add --dev lighthouse
Here, our goal is to run Lighthouse on our application whenever we run yarn deploy. To do so, we have to make a custom deploy script.
If you open up our package.json, you’ll see the following under scripts:
"scripts": {
"build": "node_modules/.bin/webpack --config webpack.config.prod.js",
"start": "node_modules/.bin/webpack-dev...