From 91ebd44446ca37c5a214d6f33ad4bcb0ea8b6852 Mon Sep 17 00:00:00 2001 From: Connor Clark Date: Mon, 11 Sep 2023 12:49:55 -0700 Subject: [PATCH] docs(plugins): minor corrections --- docs/plugins.md | 7 ++++--- docs/recipes/lighthouse-plugin-example/readme.md | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/plugins.md b/docs/plugins.md index 7f26a394c6fc..54c3575e310a 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -57,7 +57,8 @@ A Lighthouse plugin is just a node module with a name that starts with `lighthou ```json { - "name": "lighthouse-plugin-cats", + "name": "lighthouse-plugin-example", + "type": "module", "main": "plugin.js", "peerDependencies": { "lighthouse": "^11.1.0" @@ -77,7 +78,7 @@ This file contains the configuration for your plugin. It can be called anything ```js export default { // Additional audits to run on information Lighthouse gathered. - audits: [{path: 'lighthouse-plugin-cats/audits/has-cat-images.js'}], + audits: [{path: 'lighthouse-plugin-example/audits/has-cat-images.js'}], // A new category in the report for the plugin output. category: { @@ -136,7 +137,7 @@ export default CatAudit; ```sh # be in your plugin directory, and have lighthouse as a devDependency. -NODE_PATH=.. yarn lighthouse https://example.com --plugins=lighthouse-plugin-example --only-categories=lighthouse-plugin-example --view +NODE_PATH=.. npx lighthouse -- https://example.com --plugins=lighthouse-plugin-example --only-categories=lighthouse-plugin-example --view # Note: we add the parent directory to NODE_PATH as a hack to allow Lighthouse to find this plugin. # This is useful for local development, but is not necessary when your plugin consuming from NPM as # a node module. diff --git a/docs/recipes/lighthouse-plugin-example/readme.md b/docs/recipes/lighthouse-plugin-example/readme.md index 0aa82df23a04..e6a29ad70184 100644 --- a/docs/recipes/lighthouse-plugin-example/readme.md +++ b/docs/recipes/lighthouse-plugin-example/readme.md @@ -20,7 +20,7 @@ Install and run just your plugin: ```sh yarn -NODE_PATH=.. yarn lighthouse https://example.com --plugins=lighthouse-plugin-example --only-categories=lighthouse-plugin-example --view +NODE_PATH=.. npx lighthouse -- https://example.com --plugins=lighthouse-plugin-example --only-categories=lighthouse-plugin-example --view ``` When you rename the plugin, be sure to rename its directory as well. @@ -30,10 +30,10 @@ To speed up development, you can gather once and iterate by auditing repeatedly. ```sh # Gather artifacts from the browser -NODE_PATH=.. yarn lighthouse https://example.com --plugins=lighthouse-plugin-example --only-categories=lighthouse-plugin-example --gather-mode +NODE_PATH=.. npx lighthouse -- https://example.com --plugins=lighthouse-plugin-example --only-categories=lighthouse-plugin-example --gather-mode # and then iterate re-running this: -NODE_PATH=.. yarn lighthouse https://example.com --plugins=lighthouse-plugin-example --only-categories=lighthouse-plugin-example --audit-mode --view +NODE_PATH=.. npx lighthouse -- https://example.com --plugins=lighthouse-plugin-example --only-categories=lighthouse-plugin-example --audit-mode --view ``` Finally, publish to NPM. @@ -43,7 +43,7 @@ Finally, publish to NPM. 1. Install `lighthouse` (v5+) and the plugin `lighthouse-plugin-example`, likely as `devDependencies`. * `npm install -D lighthouse lighthouse-plugin-example` 1. To run your private lighthouse binary, you have three options - 1. `npx --no-install lighthouse https://example.com --plugins=lighthouse-plugin-example --view` + 1. `npx --no-install lighthouse -- https://example.com --plugins=lighthouse-plugin-example --view` 1. `yarn lighthouse https://example.com --plugins=lighthouse-plugin-example --view` 1. Add an npm script calling `lighthouse` and run that.