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
feat!: Allow running lighthouse on other pages available in publish folder (#487)
Release-As: 4.0.0
BREAKING-CHANGE: The `path` audit input option no longer affects the served directory for an audit. Use `serveDir` instead. Use `path` to specify the sub directory or `html` file within the served directory that should be audited.
Copy file name to clipboardExpand all lines: README.md
+24-9Lines changed: 24 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,14 +4,15 @@ A Netlify plugin to generate a Lighthouse report for every deploy
4
4
5
5
## Installation options
6
6
7
-
You can install the plugin for your site using your `netlify.toml` file or the Netlify UI.
7
+
You can install the plugin for your site using your `netlify.toml` file or the Netlify UI.
8
8
9
9
For the most customization options, we recommend installing the Lighthouse plugin with a `netlify.toml` file.
10
10
11
11
`netlify.toml` file-based installation allows you to:
12
-
-[Run Lighthouse audits for different site paths, such as the contact page and site home page](#run-lighthouse-for-different-site-paths)
13
-
-[Run Lighthouse audits for a desktop device](#run-lighthouse-for-the-desktop-experience)
14
-
-[Generate Lighthouse results in a language other than English](#generate-lighthouse-results-in-other-languages)
12
+
13
+
-[Run Lighthouse audits for different site paths, such as the contact page and site home page](#run-lighthouse-for-different-site-paths)
14
+
-[Run Lighthouse audits for a desktop device](#run-lighthouse-for-the-desktop-experience)
15
+
-[Generate Lighthouse results in a language other than English](#generate-lighthouse-results-in-other-languages)
15
16
16
17
### Install plugin through the Netlify UI
17
18
@@ -46,7 +47,7 @@ Then add the plugin to your `netlify.toml` configuration file:
46
47
output_path = "reports/lighthouse.html"
47
48
```
48
49
49
-
By default, the plugin will serve and audit the build directory of the site.
50
+
By default, the plugin will serve and audit the build directory of the site, inspecting the `index.html`.
50
51
You can customize the behavior via the `audits` input:
51
52
52
53
```toml
@@ -64,13 +65,27 @@ You can customize the behavior via the `audits` input:
64
65
# you can specify output_path per audit, relative to the path
65
66
output_path = "reports/route1.html"
66
67
68
+
# to audit an HTML file other than index.html in the build directory
69
+
[[plugins.inputs.audits]]
70
+
path = "contact.html"
71
+
72
+
# to audit an HTML file other than index.html in a sub path of the build directory
73
+
[[plugins.inputs.audits]]
74
+
path = "pages/contact.html"
75
+
67
76
# to audit a specific absolute url
68
77
[[plugins.inputs.audits]]
69
78
url = "https://www.example.com"
70
79
71
80
# you can specify thresholds per audit
72
81
[plugins.inputs.audits.thresholds]
73
82
performance = 0.8
83
+
84
+
# to serve only a sub directory of the build directory for an audit
85
+
# pages/index.html will be audited, and files outside of this directory will not be served
86
+
[[plugins.inputs.audits]]
87
+
serveDir = "pages"
88
+
74
89
```
75
90
76
91
The lighthouse scores are automatically printed to the **Deploy log** in the Netlify UI. For example:
@@ -103,7 +118,7 @@ To customize how Lighthouse runs audits, you can make changes to the `netlify.to
103
118
104
119
By default, Lighthouse takes a mobile-first performance testing approach and runs audits for the mobile device experience. You can optionally run Lighthouse audits for the desktop experience by including `preset = "desktop"` in your `netlify.toml` file:
105
120
106
-
```
121
+
```toml
107
122
[[plugins]]
108
123
package = "@netlify/plugin-lighthouse"
109
124
@@ -117,15 +132,15 @@ To return to running Lighthouse audits for the mobile experience, just remove th
117
132
118
133
### Generate Lighthouse results in other languages
119
134
120
-
By default, Lighthouse results are generated in English. To return Lighthouse results in other languages, include the language code from any Lighthouse-supported locale in your `netlify.toml` file.
135
+
By default, Lighthouse results are generated in English. To return Lighthouse results in other languages, include the language code from any Lighthouse-supported locale in your `netlify.toml` file.
121
136
122
137
For the latest Lighthouse supported locales or language codes, check out this [official Lighthouse code](https://github.com/GoogleChrome/lighthouse/blob/da3c865d698abc9365fa7bb087a08ce8c89b0a05/types/lhr/settings.d.ts#L9).
123
138
124
139
Updates to `netlify.toml` will take effect for new builds.
125
140
126
141
#### Example to generate Lighthouse results in Spanish
127
142
128
-
```
143
+
```toml
129
144
[[plugins]]
130
145
package = "@netlify/plugin-lighthouse"
131
146
@@ -146,7 +161,7 @@ yarn local
146
161
147
162
## Preview Lighthouse results within the Netlify UI
148
163
149
-
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.
164
+
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.
150
165
151
166
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.
0 commit comments