-
Notifications
You must be signed in to change notification settings - Fork 30
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
feat!: Run plugin on live deploy URL by default #588
Conversation
…y_on_failed_threshold for onPostBuild event
👷 Deploy Preview for plugin-lighthouse processing.
|
output_path = "reports/route1.html" | ||
|
||
# to audit an HTML file other than index.html in the build directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of options are specific only to the onPostBuild
behaviour (e.g. which directory to serve, file names other than index.html
) so have been moved to the new/separate section
process.env.LIGHTHOUSE_RUN_ON_SUCCESS === 'true' | ||
? 'onSuccess' | ||
: 'onPostBuild'; | ||
inputs?.fail_deploy_on_score_thresholds === 'true' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main change in this PR - pretty much everything else is docs changes or updating tests to include fail_deploy_on_score_thresholds
/ remove the old env variable for onSuccess
Test steps for this PRCheck the new default behaviourUsing a test site,
Check the old
|
@@ -173,21 +184,13 @@ yarn local | |||
|
|||
## Preview Lighthouse results within the Netlify UI | |||
|
|||
Netlify offers an experimental feature through Netlify Labs that allows you to view Lighthouse scores for each of your builds on your site's Deploy Details page with a much richer format. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section was incorrectly referencing the feature being in Labs, seems it got missed in a previous cleanup. I've also added some new screenshots to bring them a bit more up to date
@@ -6,7 +6,7 @@ | |||
"packages": { | |||
"": { | |||
"name": "@netlify/plugin-lighthouse", | |||
"version": "4.0.7", | |||
"version": "4.1.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed by previous release(s)
All manual tests/edge cases checked, just putting a pin in this for now so docs has a chance to weigh in 📌 |
#### Fail a deploy based on score thresholds | ||
|
||
By default, the lighthouse plugin will run _after_ your deploy has been successful, auditing the live deploy content. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth adding a note about the limitations, e.g. the site needs to be pre-built – no SSR etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great callout! I've added a sentence that uses similar wording to what we currently have on the docs page 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you so much for getting this over the line 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes you made to the README look good to me, but I found a few pre-existing things in code blocks that could use further tidying up to align with the other changes you made.
|
||
By default, the lighthouse plugin will run _after_ your deploy has been successful, auditing the live deploy content. | ||
|
||
To run the plugin _before_ the deploy is live, use the `fail_deploy_on_score_thresholds` input to instead run during the `onPostBuild` event. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Earlier on the page, under "The lighthouse scores are automatically printed to the Deploy log in the Netlify UI. For example:" the example deploy log output shows the plugin running at the onPostBuild
stage

Since this is no longer the default behavior, and this option isn't introduced until after the deploy log example, it could be helpful to update the deploy log example to be more representative of what folks get by default.
To run the plugin _before_ the deploy is live, use the `fail_deploy_on_score_thresholds` input to instead run during the `onPostBuild` event. | ||
This will statically serve your build output folder, and audit the `index.html` (or other file if specified as below). Please note that sites or site paths using SSR/ISR (server-side rendering or Incremental Static Regeneration) cannot be served and audited in this way. | ||
|
||
Using this configuration, if minimum threshold scores are supplied and not met, the deploy will fail. Set the threshold based on `performance`, `accessibility`, `best-practices`, `seo`, or `pwa`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
earlier on the page, the code sample under "Then add the plugin to your netlify.toml configuration file:" shows thresholds being configured without fail_deploy_on_score_thresholds = "true"

Since the thresholds won't do anything without fail_deploy_on_score_thresholds = "true"
, I think it would be good to remove them from that initial toml sample
Great call outs - thank you! I've updated those sections now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes - LGTM!
Great work @aitchiss! |
1. Lighthouse plugin config - set `fail_deploy_on_score_thresholds = "true”` in `[plugins.inputs]` to get some of the old behavior back. mastodon discussion: https://mastodon.social/@rdela/112208080966164909 - PR 588 netlify/netlify-plugin-lighthouse#588 Looks like a bunch of the config options and behavior changed and then netlify disabled issues - netlify-plugin-lighthouse is now in maintenance(-only) mode https://github.com/netlify/netlify-plugin-lighthouse/blob/main/CONTRIBUTING.md https://fosstodon.org/@eleventy/112208087737676821 - explain lowering of seo failure threshold due to `x-robots-tag: noindex` header set on deploy previews 2. about page file links - these worked in README but needed full URLs to trunk branch for the site
* fix: Lighthouse plugin config and about page file links 1. Lighthouse plugin config - set `fail_deploy_on_score_thresholds = "true”` in `[plugins.inputs]` to get some of the old behavior back. mastodon discussion: https://mastodon.social/@rdela/112208080966164909 - PR 588 netlify/netlify-plugin-lighthouse#588 Looks like a bunch of the config options and behavior changed and then netlify disabled issues - netlify-plugin-lighthouse is now in maintenance(-only) mode https://github.com/netlify/netlify-plugin-lighthouse/blob/main/CONTRIBUTING.md https://fosstodon.org/@eleventy/112208087737676821 - explain lowering of seo failure threshold due to `x-robots-tag: noindex` header set on deploy previews 2. about page file links - these worked in README but needed full URLs to trunk branch for the site
Closes #587
We previous released the ability to run the plugin during the
onSuccess
build step as experimental/undocumented functionality. We've had good feedback from users and are now ready to roll this out as the default behaviour.The plugin will now run after a deploy has completed auditing the live deploy rather than the statically served build folder. This will:
The main side effect of this change is that if score thresholds have been configured, the plugin will no longer fail the deploy if those scores are not met.
To continue running the plugin
onPostBuild
(i.e. before the deploy is complete, using the statically served build folder) and maintain the "fail on thresholds" functionality, setfail_deploy_on_score_thresholds
to'true'
innetlify.toml
:If your configuration currently relies on
serveDir
to ensure the correct page(s) are audited, please note this will have no impact on the new default plugin behaviour. Either continue to run during theonPostBuild
stage via the above steps, or amend yourpath
input(s) to ensure the full page route is specified.For example -
Old configuration relying on
serveDir
:New configuration not relying on
serveDir
: