Skip to content

Multiple URLs in Lighthouse plugin #1008

@matejchalk

Description

@matejchalk

User story

As a user, I would like to run Lighthouse on multiple pages in my app, to get a more holistic report of my app's performance, accessibility, etc. But the Lighthouse plugin currently only supports a single URL.

Proposal

We can easily accept an array of URLs and orchestrate multiple Lighthouse reports. The more tricky question is how to process the results from multiple pages. Lighthouse CI creates separate Lighthouse reports per page and doesn't attempt to aggregate them in any way.

The most reasonable solution is to generate the same audits and groups for each page - slugs would be performance-1, accessibility-1, performance-2, etc (display titles would include the source URL for readability). These could then be combined into a single category using multiple refs (e.g. performance category will reference groups performance-1, performance-2, etc.) - we could provide a helper function for that.

import lighthousePlugin, { mergeLighthouseCategoriesFromUrls } from '@code-pushup/lighthouse-plugin';

const lhPlugin = lighthousePlugin([
  'https://example.com',
  'https://example.com/about',
  'https://example.com/contact'
]);

export default {
  plugins: [
    lhPlugin,
    // ... other plugins ...
  ],
  categories: [
     ...mergeLighthouseCategories(lhPlugin),
     // ... other categories ...
  ],
};

Since it's likely that some pages in an application will be more likely than others, we could enable users to each URL their own weight to reflect this in the score calculation.

lighthousePlugin({
  'https://example.com': 2,
  'https://example.com/about': 1
  'https://example.com/contact': 1,
});

Acceptance criteria

  • support array of URLs in lighthousePlugin function
  • generate distinct audits and groups for each URL
  • run lighthouse for each URL sequentially
  • provide helper function which configures combined categories for each URL's report
  • enable user to provide custom weights per URL (optional, default will be uniform weight)
  • single URL usage stays the same (simpler to get started)

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions