0.10.1 • Published 5 months ago

astro-page-insight v0.10.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

astro-page-insight

npm.io

docs | demo

This is an Astro integration that shows everything to improve from Lighthouse results directly on the page.

!IMPORTANT This result is by dev mode, so it may not be accurate.
Especially, the Score is not accurate.

Usage

Prerequisites

Astro 4.0 or later is required.

Installation

Install the integration automatically using the Astro CLI:

pnpm astro add astro-page-insight
npx astro add astro-page-insight
yarn astro add astro-page-insight

Or install it manually:
1. Install the required dependencies

pnpm add astro-page-insight
npm install astro-page-insight
yarn add astro-page-insight
  1. Add the integration to your astro config
+import pageInsight from "astro-page-insight";

export default defineConfig({
  integrations: [
+    pageInsight(),
  ],
});

Configuration

Here is the options:

PropertyTypeDefaultDescription
lh.weightnumber0weight is the threshold value in the audit.
lh.breakPointnumber767breakPoint is used to determine whether on mobile or desktop.
firstFetchload, open, nonenonefirstFetch is used for when to do the first fetch.if firstFetch is load, will fetch on page load.if firstFetch is open, will fetch on first app open.if firstFetch is none, only fetch on user interaction.
cachebooleanfalsecache is used to enable the cache.if cache is true, will enable to cache the lighthouse report.
build.bundlebooleanfalsebundle is used to determine whether to bundle the page insight.if bundle is true, will bundle the page insight. so you can see the insight after build.It will bundle results from local cache.
build.showOnLoadbooleanfalseshowOnLoad is used to determine whether to show the page insight on page load.if showOnLoad is true, will show the page insight on page load.

Example

import pageInsight from "astro-page-insight";

export default defineConfig({
  integrations: [
    pageInsight({
      lh: {
        weight: 0.5,
        breakPoint: 1024,
      },
      firstFetch: "open",
      cache: true,
      build: {
        bundle: true, // You should get value from the environment variable. (e.g. process.env.STAGING === "true")
        showOnLoad: true, // This option is only available when `bundle` is `true`.
      },
    }),
  ],
});

gitignore

If you want to ignore the cache, add the following to your .gitignore:

+ .pageinsight

Notification

You can sometimes see that the notification is displayed in the app.
There are three types of notifications:

ColorDescription
Blueblue means that results are fresh.
Yellowyellow has two meanings.One is that the results are from the cache.The other is that fetching is in progress.
Redred means that fetching failed.

build.bundle

If you set build.bundle to true, It will bundle results from local cache, So you need to have lighthouse results(cache) on build time.

Contributing

This package is structured as a monorepo:

  • playground contains code for testing the package
  • package contains the actual package

Install dependencies using pnpm:

pnpm i --frozen-lockfile

Watch for package changes:

pnpm package:dev

Start the playground with blog:

pnpm playground:blog

Start the playground with ssr:

pnpm playground:ssr

Start the playground with starlog:

pnpm playground:starlog

You can now edit files in package. Please note that making changes to those files may require restarting the playground dev server.

Licensing

MIT Licensed. Made with ❤️ by ktym4a.

0.10.1

5 months ago

0.10.0

6 months ago

0.9.0

8 months ago

0.8.7

9 months ago

0.8.6

10 months ago

0.8.5

11 months ago

0.8.4

12 months ago

0.8.3

1 year ago

0.8.2

1 year ago

0.8.1

1 year ago

0.8.0

1 year ago

0.6.4

1 year ago

0.7.0

1 year ago

0.6.3

1 year ago

0.6.2

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.4

1 year ago

0.5.3

1 year ago

0.5.2

1 year ago

0.5.1

1 year ago

0.5.0

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago

0.1.1

1 year ago

0.0.17

1 year ago

0.0.18

1 year ago

0.0.15

1 year ago

0.0.16

1 year ago

0.0.10

1 year ago

0.0.11

1 year ago

0.0.12

1 year ago

0.0.13

1 year ago

0.0.14

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago