@@ -11,6 +11,7 @@ dotenv.config();
11
11
const puppeteerCacheDir = join ( homedir ( ) , '.cache' , 'puppeteer' ) ;
12
12
13
13
const onPreBuild = async ( { utils } = { } ) => {
14
+ console . log ( 'onPreBuild handler called' ) ;
14
15
console . log ( 'Restoring Lighthouse cache...' ) ;
15
16
// Puppeteer relies on a global cache since v19.x, which otherwise would not be persisted in Netlify builds
16
17
await utils ?. cache . restore ( puppeteerCacheDir ) ;
@@ -24,6 +25,7 @@ const persistCache = async ({ utils } = {}) => {
24
25
} ;
25
26
26
27
export default function lighthousePlugin ( inputs ) {
28
+ console . log ( 'lighthouse plugin function called with inputs:' , JSON . stringify ( inputs , null , 2 ) ) ;
27
29
// Run onSuccess by default, unless inputs specify we should fail_deploy_on_score_thresholds
28
30
const defaultEvent =
29
31
inputs ?. fail_deploy_on_score_thresholds === 'true'
@@ -33,8 +35,12 @@ export default function lighthousePlugin(inputs) {
33
35
if ( defaultEvent === 'onSuccess' ) {
34
36
return {
35
37
onPreBuild,
36
- onPostBuild : ( { utils } ) => persistCache ( { utils } ) ,
38
+ onPostBuild : ( { utils } ) => {
39
+ console . log ( 'onPostBuild handler called (onSuccess mode)' ) ;
40
+ return persistCache ( { utils } ) ;
41
+ } ,
37
42
onSuccess : async ( { constants, utils, inputs } = { } ) => {
43
+ console . log ( 'onSuccess handler called' ) ;
38
44
// Mock the required `utils` functions if running locally
39
45
const { failPlugin, show } = getUtils ( { utils } ) ;
40
46
@@ -51,6 +57,7 @@ export default function lighthousePlugin(inputs) {
51
57
return {
52
58
onPreBuild,
53
59
onPostBuild : async ( { constants, utils, inputs } = { } ) => {
60
+ console . log ( 'onPostBuild handler called (onPostBuild mode)' ) ;
54
61
// Mock the required `utils` functions if running locally
55
62
const { failBuild, show } = getUtils ( { utils } ) ;
56
63
0 commit comments