@code-pushup/lighthouse-plugin 0.51.0 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -13
- package/index.js +5 -3
- package/package.json +7 -3
- package/src/index.d.ts +1 -1
- package/src/lib/constants.d.ts +1 -0
package/README.md
CHANGED
|
@@ -119,24 +119,27 @@ export default {
|
|
|
119
119
|
|
|
120
120
|
## Flags
|
|
121
121
|
|
|
122
|
-
The plugin accepts
|
|
122
|
+
The plugin accepts an optional second argument, `flags`.
|
|
123
123
|
|
|
124
|
-
`flags` is
|
|
124
|
+
`flags` is a JavaScript object containing Lighthouse [CLI flags](https://github.com/GoogleChrome/lighthouse/blob/7d80178c37a1b600ea8f092fc0b098029799a659/cli/cli-flags.js#L80).
|
|
125
125
|
|
|
126
|
-
Within the flags object
|
|
126
|
+
Within the `flags` object, external configuration files can be referenced using options like `configPath` , `preset`, or `budgetPath`. These options allow Lighthouse to load custom configurations, audit presets, or performance budgets from external `json` or JavaScript files.
|
|
127
127
|
|
|
128
|
-
For a complete list the
|
|
128
|
+
For a complete list of available options, refer to [the official Lighthouse documentation](https://github.com/GoogleChrome/lighthouse/blob/main/readme.md#cli-options).
|
|
129
129
|
|
|
130
130
|
> [!TIP]
|
|
131
|
-
> If you are
|
|
131
|
+
> If you are new to working with the Lighthouse CLI, flags can be passed like this:
|
|
132
132
|
> `lighthouse https://example.com --output=json --chromeFlags='--headless=shell'`
|
|
133
133
|
>
|
|
134
|
-
>
|
|
134
|
+
> With the plugin, the configuration would be:
|
|
135
135
|
>
|
|
136
136
|
> ```ts
|
|
137
137
|
> // code-pushup.config.ts
|
|
138
138
|
> ...
|
|
139
|
-
> lighthousePlugin('https://example.com', {
|
|
139
|
+
> lighthousePlugin('https://example.com', {
|
|
140
|
+
> output: 'json',
|
|
141
|
+
> chromeFlags: ['--headless=shell'],
|
|
142
|
+
> });
|
|
140
143
|
> ```
|
|
141
144
|
|
|
142
145
|
> [!note]
|
|
@@ -149,14 +152,47 @@ For a complete list the [official documentation of CLI flags](https://github.com
|
|
|
149
152
|
|
|
150
153
|
## Chrome Flags for Tooling
|
|
151
154
|
|
|
152
|
-
We recommend using Chrome flags for more stable runs in a tooling environment.
|
|
153
|
-
|
|
155
|
+
We recommend using Chrome flags for more stable runs in a tooling environment. The [`chrome-launcher`](https://www.npmjs.com/package/chrome-launcher) package offers a well-documented set of flags specifically designed to ensure reliable execution.
|
|
156
|
+
|
|
157
|
+
The latest version of `@code-pushup/lighthouse-plugin` provides `DEFAULT_CHROME_FLAGS`, a pre-configured constant that includes Chrome’s default flags for stable, headless execution out of the box. This means you do not need to specify `chromeFlags` manually unless you want to modify them.
|
|
158
|
+
|
|
159
|
+
### Default Usage
|
|
160
|
+
|
|
161
|
+
If no `chromeFlags` are provided, the plugin automatically applies the default configuration:
|
|
154
162
|
|
|
155
163
|
> ```ts
|
|
156
|
-
>
|
|
157
|
-
>
|
|
158
|
-
>
|
|
159
|
-
>
|
|
164
|
+
> import lighthousePlugin from '@code-pushup/lighthouse-plugin';
|
|
165
|
+
>
|
|
166
|
+
> lighthousePlugin('https://example.com', {
|
|
167
|
+
> output: 'json',
|
|
168
|
+
> // Defaults to DEFAULT_CHROME_FLAGS internally
|
|
169
|
+
> });
|
|
170
|
+
> ```
|
|
171
|
+
|
|
172
|
+
### Adding Extra Flags
|
|
173
|
+
|
|
174
|
+
If additional Chrome flags are required (e.g., verbose logging or debugging), they can be appended to the default flags:
|
|
175
|
+
|
|
176
|
+
> ```ts
|
|
177
|
+
> import lighthousePlugin, { DEFAULT_CHROME_FLAGS } from '@code-pushup/lighthouse-plugin';
|
|
178
|
+
>
|
|
179
|
+
> lighthousePlugin('https://example.com', {
|
|
180
|
+
> output: 'json',
|
|
181
|
+
> chromeFlags: DEFAULT_CHROME_FLAGS.concat(['--verbose']),
|
|
182
|
+
> });
|
|
183
|
+
> ```
|
|
184
|
+
|
|
185
|
+
### Overriding Default Flags
|
|
186
|
+
|
|
187
|
+
To completely override the default flags and provide a custom configuration:
|
|
188
|
+
|
|
189
|
+
> ```ts
|
|
190
|
+
> import lighthousePlugin from '@code-pushup/lighthouse-plugin';
|
|
191
|
+
>
|
|
192
|
+
> lighthousePlugin('https://example.com', {
|
|
193
|
+
> output: 'json',
|
|
194
|
+
> chromeFlags: ['--verbose'],
|
|
195
|
+
> });
|
|
160
196
|
> ```
|
|
161
197
|
|
|
162
198
|
## Config
|
package/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// packages/plugin-lighthouse/package.json
|
|
2
2
|
var name = "@code-pushup/lighthouse-plugin";
|
|
3
|
-
var version = "0.
|
|
3
|
+
var version = "0.53.0";
|
|
4
4
|
|
|
5
5
|
// packages/plugin-lighthouse/src/lib/constants.ts
|
|
6
|
+
import { DEFAULT_FLAGS } from "chrome-launcher/dist/flags.js";
|
|
6
7
|
import { join } from "node:path";
|
|
7
8
|
|
|
8
9
|
// packages/models/src/lib/implementation/schemas.ts
|
|
@@ -709,6 +710,7 @@ var reportsDiffSchema = z16.object({
|
|
|
709
710
|
);
|
|
710
711
|
|
|
711
712
|
// packages/plugin-lighthouse/src/lib/constants.ts
|
|
713
|
+
var DEFAULT_CHROME_FLAGS = [...DEFAULT_FLAGS, "--headless"];
|
|
712
714
|
var LIGHTHOUSE_PLUGIN_SLUG = "lighthouse";
|
|
713
715
|
var LIGHTHOUSE_OUTPUT_PATH = join(
|
|
714
716
|
DEFAULT_PERSIST_OUTPUT_DIR,
|
|
@@ -1052,8 +1054,7 @@ var DEFAULT_CLI_FLAGS = {
|
|
|
1052
1054
|
// https://github.com/GoogleChrome/lighthouse/blob/7d80178c37a1b600ea8f092fc0b098029799a659/cli/cli-flags.js#L80
|
|
1053
1055
|
verbose: false,
|
|
1054
1056
|
saveAssets: false,
|
|
1055
|
-
|
|
1056
|
-
chromeFlags: ["--headless=shell"],
|
|
1057
|
+
chromeFlags: DEFAULT_CHROME_FLAGS,
|
|
1057
1058
|
port: 0,
|
|
1058
1059
|
hostname: "127.0.0.1",
|
|
1059
1060
|
view: false,
|
|
@@ -1627,6 +1628,7 @@ function lighthousePlugin(url, flags) {
|
|
|
1627
1628
|
// packages/plugin-lighthouse/src/index.ts
|
|
1628
1629
|
var src_default = lighthousePlugin;
|
|
1629
1630
|
export {
|
|
1631
|
+
DEFAULT_CHROME_FLAGS,
|
|
1630
1632
|
LIGHTHOUSE_OUTPUT_PATH,
|
|
1631
1633
|
LIGHTHOUSE_PLUGIN_SLUG,
|
|
1632
1634
|
LIGHTHOUSE_REPORT_NAME,
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/lighthouse-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.53.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Code PushUp plugin for measuring web performance and quality with Lighthouse 🔥",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@code-pushup/models": "0.
|
|
8
|
-
"@code-pushup/utils": "0.
|
|
7
|
+
"@code-pushup/models": "0.53.0",
|
|
8
|
+
"@code-pushup/utils": "0.53.0",
|
|
9
9
|
"ansis": "^3.3.0",
|
|
10
|
+
"chrome-launcher": "^1.1.1",
|
|
10
11
|
"lighthouse": "^12.0.0",
|
|
11
12
|
"lighthouse-logger": "2.0.1"
|
|
12
13
|
},
|
|
@@ -19,6 +20,9 @@
|
|
|
19
20
|
"url": "git+https://github.com/code-pushup/cli.git",
|
|
20
21
|
"directory": "packages/plugin-lighthouse"
|
|
21
22
|
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
22
26
|
"type": "module",
|
|
23
27
|
"main": "./index.js",
|
|
24
28
|
"types": "./src/index.d.ts"
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { lighthousePlugin } from './lib/lighthouse-plugin';
|
|
2
2
|
export { LIGHTHOUSE_REPORT_NAME } from './lib/runner';
|
|
3
|
-
export { LIGHTHOUSE_PLUGIN_SLUG, LIGHTHOUSE_OUTPUT_PATH, } from './lib/constants';
|
|
3
|
+
export { DEFAULT_CHROME_FLAGS, LIGHTHOUSE_PLUGIN_SLUG, LIGHTHOUSE_OUTPUT_PATH, } from './lib/constants';
|
|
4
4
|
export { lighthouseAuditRef, lighthouseGroupRef, type LighthouseGroupSlugs, } from './lib/utils';
|
|
5
5
|
export type { LighthouseOptions } from './lib/types';
|
|
6
6
|
export { lighthousePlugin } from './lib/lighthouse-plugin';
|
package/src/lib/constants.d.ts
CHANGED