3.1.0 • Published 6 years ago

@dreipol/lighthouse-config v3.1.0

Weekly downloads
6
License
MIT
Repository
github
Last release
6 years ago

@dreipol/lighthouse-config

Centralized location to hold the @dreipol/lighthouse-runner default configuration

Install

npm i @dreipol/lighthouse-config

Setup

This module simply provides some default configuration. You can extend this config to your flavour. Therefore no setup for this module is required.

Config

fieldtypedefaultvalue
pathsArray['/']Array of url paths. All these routes are tested and reported
chromeFlagsArray['--window-size=1200,800']Array of additional chrome flags. See all
folderstring./dreihouse-reportsDefine location to store the reports
disableEmulationbooleantrueApplay device emulation
disableThrottlingbooleantrueDisable Network and CPU throttling
preAuditScriptsArray['html']Current available persisters are html json and `html-dashboard
reportObjectLighthouse report configurations. See exmaples

preAuditScripts

In order to handle login forms, or do other modifications of the page before lighthouse audits the page, you can add some preAuditScripts in the config. Those scripts are executed right before lighthouse starts. These scripts have to implement the PreAuditScriptInterface interface.

Before execution of this script, the browser instance will already be on the inital url, passed in the execute method of Dreihouse

Here is an example of such login script

module.exports = {
    execute:async(logger, page) {
        await page.waitForSelector('#username', { visible: true });
        await page.waitForSelector('#password', { visible: true });
        
        const usernameInput = await page.$('#username');
        const passwordInput = await page.$('#password');
        
        await usernameInput.type(process.env.LOGIN_USERNAME);
        await passwordInput.type(process.env.LOGIN_PASSWORD);
        
        await passwordInput.press('Enter');
    }
}

Now in your config file you can load the login script

...
saveReport: true,
budget: {
    ...
},
preAuditScripts: [
    require('your/login/script.js'),
],
reporters: {
    modules: [
        ...
        
        

Example

paths: [
    '/',
],
folder: "./dreihouse-reports",
tag: 'desktop',
chromeFlags: ['--window-size=1280,1024'],
disableEmulation: true,
disableThrottling: true,
budget: {
    dreipol: 100,
    seo: 90,
    performance: 90,
    pwa: 70,
    accessibility: 70,
    'best-practices': 70,
},
report: {...}

Extend from the base config

You can extend the base configuration with your own configuration. This is done by creating a new config file in your project and include the base config via require. Then you can edit the Object the way you want

Example for local mobile config:

let mobileConfig = require('@dreipol/lighthouse-config/config/base/desktop');

mobileConfig.chromeFlags = ['--window-size=320,480'];
mobileConfig.disableEmulation = false;
mobileConfig.disableThrottling = false;

module.exports = mobileConfig;
3.1.0

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.12.0

6 years ago

0.11.6

6 years ago

0.11.5

6 years ago

0.11.4

6 years ago

0.11.3

6 years ago

0.11.2

6 years ago

0.11.1

6 years ago

0.11.0

6 years ago

0.10.0

6 years ago

0.9.0

6 years ago

0.8.0

6 years ago

0.7.0

6 years ago

0.6.0

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago