You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2:35:07 PM: Serving and scanning site from directory dist
@@ -73,32 +65,25 @@ The lighthouse scores are automatically printed to the **Deploy log** in the Net
73
65
74
66
To customize how Lighthouse runs audits, you can make changes to the `netlify.toml` file.
75
67
76
-
By default, the plugin will serve and audit the build directory of the site, inspecting the `index.html`.
77
-
You can customize the behavior via the `audits` input:
68
+
By default, the plugin will run after your build is deployed on the live deploy permalink, inspecting the home path `/`.
69
+
You can add additional configuration and/or inspect a different path, or multiple additional paths by adding configuration in the `netlify.toml` file:
78
70
79
71
```toml
80
72
[[plugins]]
81
73
package = "@netlify/plugin-lighthouse"
82
74
75
+
# Set minimum thresholds for each report area
83
76
[plugins.inputs.thresholds]
84
77
performance = 0.9
85
78
86
-
# to audit a sub path of the build directory
79
+
# to audit a path other than /
87
80
# route1 audit will use the top level thresholds
88
81
[[plugins.inputs.audits]]
89
82
path = "route1"
90
83
91
-
# you can specify output_path per audit, relative to the path
84
+
# you can optionally specify an output_path per audit, relative to the path, where HTML report output will be saved
92
85
output_path = "reports/route1.html"
93
86
94
-
# to audit an HTML file other than index.html in the build directory
95
-
[[plugins.inputs.audits]]
96
-
path = "contact.html"
97
-
98
-
# to audit an HTML file other than index.html in a sub path of the build directory
99
-
[[plugins.inputs.audits]]
100
-
path = "pages/contact.html"
101
-
102
87
# to audit a specific absolute url
103
88
[[plugins.inputs.audits]]
104
89
url = "https://www.example.com"
@@ -107,11 +92,42 @@ You can customize the behavior via the `audits` input:
107
92
[plugins.inputs.audits.thresholds]
108
93
performance = 0.8
109
94
95
+
```
96
+
97
+
#### Fail a deploy based on score thresholds
98
+
99
+
By default, the lighthouse plugin will run _after_ your deploy has been successful, auditing the live deploy content.
100
+
101
+
To run the plugin _before_ the deploy is live, use the `fail_deploy_on_score_thresholds` input to instead run during the `onPostBuild` event.
102
+
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.
103
+
104
+
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`.
105
+
106
+
```toml
107
+
[[plugins]]
108
+
package = "@netlify/plugin-lighthouse"
109
+
110
+
# Set the plugin to run prior to deploy, failing the build if minimum thresholds aren't set
111
+
[plugins.inputs]
112
+
fail_deploy_on_score_thresholds = "true"
113
+
114
+
# Set minimum thresholds for each report area
115
+
[plugins.inputs.thresholds]
116
+
performance = 0.9
117
+
accessibility: = 0.7
118
+
119
+
# to audit an HTML file other than index.html in the build directory
120
+
[[plugins.inputs.audits]]
121
+
path = "contact.html"
122
+
123
+
# to audit an HTML file other than index.html in a sub path of the build directory
124
+
[[plugins.inputs.audits]]
125
+
path = "pages/contact.html"
126
+
110
127
# to serve only a sub directory of the build directory for an audit
111
128
# pages/index.html will be audited, and files outside of this directory will not be served
112
129
[[plugins.inputs.audits]]
113
130
serveDir = "pages"
114
-
115
131
```
116
132
117
133
### Run Lighthouse audits for desktop
@@ -148,18 +164,6 @@ Updates to `netlify.toml` will take effect for new builds.
148
164
locale = "es"# generates Lighthouse reports in Español
149
165
```
150
166
151
-
### Fail Builds Based on Score Thresholds
152
-
153
-
By default, the Lighthouse plugin will report the findings in the deploy logs. To fail a build based on a specific score, specify the inputs thresholds in your `netlify.toml` file. Set the threshold based on `performance`, `accessibility`, `best-practices`, `seo`, or `pwa`.
154
-
155
-
```toml
156
-
[[plugins]]
157
-
package = "@netlify/plugin-lighthouse"
158
-
159
-
[plugins.inputs.thresholds]
160
-
performance = 0.9
161
-
```
162
-
163
167
### Run Lighthouse Locally
164
168
165
169
Fork and clone this repo.
@@ -173,21 +177,13 @@ yarn local
173
177
174
178
## Preview Lighthouse results within the Netlify UI
175
179
176
-
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.
177
-
178
-
You'll need to install the [Lighthouse build plugin](https://app.netlify.com/plugins/@netlify/plugin-lighthouse/install) on your site and then enable this experimental feature through Netlify Labs.
179
-
180
-
<imgwidth="1400"alt="Deploy view with Lighthouse visualizations"src="https://user-images.githubusercontent.com/79875905/160019039-c3e529de-f389-42bc-a3d4-458c90d59e6a.png">
181
-
182
-
If you have multiple audits (directories, paths, etc) defined in your build, we will display a roll-up of the average Lighthouse scores for all the current build's audits plus the results for each individual audit.
180
+
The Netlify UI allows you to view Lighthouse scores for each of your builds on your site's Deploy Details page with a much richer format.
183
181
184
-
<imgwidth="1400"alt="Deploy details with multiple audit Lighthouse results"src="https://user-images.githubusercontent.com/79875905/160019057-d29dffab-49f3-4fbf-a1ac-1f314e0cd837.png">
182
+
You'll need to first install the [Lighthouse build plugin](https://app.netlify.com/plugins/@netlify/plugin-lighthouse/install) on your site.
185
183
186
-
Some items of note:
184
+
<imgwidth="1400"alt="Deploy view with Lighthouse visualizations"src="https://github.com/netlify/netlify-plugin-lighthouse/assets/20773163/144d7bd3-5b7b-4a18-826e-c8d582f92fab">
187
185
188
-
- The [Lighthouse Build Plugin](https://app.netlify.com/plugins/@netlify/plugin-lighthouse/install) must be installed on your site(s) in order for these score visualizations to be displayed.
189
-
- This Labs feature is currently only enabled at the user-level, so it will need to be enabled for each individual team member that wishes to see the Lighthouse scores displayed.
186
+
If you have multiple audits (e.g. multiple paths) defined in your build, we will display a roll-up of the average Lighthouse scores for all the current build's audits plus the results for each individual audit.
190
187
191
-
Learn more in our official [Labs docs](https://docs.netlify.com/netlify-labs/experimental-features/lighthouse-visualization/).
188
+
<imgwidth="1400"alt="Deploy details with multiple audit Lighthouse results"src="https://github.com/netlify/netlify-plugin-lighthouse/assets/20773163/b9887c64-db03-40c0-b7e9-5acba081f87b">
192
189
193
-
We have a lot planned for this feature and will be adding functionality regularly, but we'd also love to hear your thoughts. Please [share your feedback](https://netlify.qualtrics.com/jfe/form/SV_1NTbTSpvEi0UzWe) about this experimental feature and tell us what you think.
Copy file name to clipboardExpand all lines: src/e2e/not-found-onpostbuild.test.js
+9-3Lines changed: 9 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,9 @@ describe('lighthousePlugin with single not-found run (onPostBuild)', () => {
32
32
'Lighthouse was unable to reliably load the page you requested. Make sure you are testing the correct URL and that the server is properly responding to all requests. (Status code: 404)',
@@ -52,14 +54,18 @@ describe('lighthousePlugin with single not-found run (onPostBuild)', () => {
52
54
"Error testing 'example/this-page-does-not-exist': Lighthouse was unable to reliably load the page you requested. Make sure you are testing the correct URL and that the server is properly responding to all requests. (Status code: 404)",
0 commit comments