Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(plugins): minor corrections #15449

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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: {
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions docs/recipes/lighthouse-plugin-example/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.

Expand Down
Loading