@@ -11,6 +11,7 @@ dotenv.config();
1111const puppeteerCacheDir = join ( homedir ( ) , '.cache' , 'puppeteer' ) ;
1212
1313const onPreBuild = async ( { utils } = { } ) => {
14+ console . log ( 'onPreBuild handler called' ) ;
1415 console . log ( 'Restoring Lighthouse cache...' ) ;
1516 // Puppeteer relies on a global cache since v19.x, which otherwise would not be persisted in Netlify builds
1617 await utils ?. cache . restore ( puppeteerCacheDir ) ;
@@ -24,6 +25,7 @@ const persistCache = async ({ utils } = {}) => {
2425} ;
2526
2627export default function lighthousePlugin ( inputs ) {
28+ console . log ( 'lighthouse plugin function called with inputs:' , JSON . stringify ( inputs , null , 2 ) ) ;
2729 // Run onSuccess by default, unless inputs specify we should fail_deploy_on_score_thresholds
2830 const defaultEvent =
2931 inputs ?. fail_deploy_on_score_thresholds === 'true'
@@ -33,8 +35,12 @@ export default function lighthousePlugin(inputs) {
3335 if ( defaultEvent === 'onSuccess' ) {
3436 return {
3537 onPreBuild,
36- onPostBuild : ( { utils } ) => persistCache ( { utils } ) ,
38+ onPostBuild : ( { utils } ) => {
39+ console . log ( 'onPostBuild handler called (onSuccess mode)' ) ;
40+ return persistCache ( { utils } ) ;
41+ } ,
3742 onSuccess : async ( { constants, utils, inputs } = { } ) => {
43+ console . log ( 'onSuccess handler called' ) ;
3844 // Mock the required `utils` functions if running locally
3945 const { failPlugin, show } = getUtils ( { utils } ) ;
4046
@@ -51,6 +57,7 @@ export default function lighthousePlugin(inputs) {
5157 return {
5258 onPreBuild,
5359 onPostBuild : async ( { constants, utils, inputs } = { } ) => {
60+ console . log ( 'onPostBuild handler called (onPostBuild mode)' ) ;
5461 // Mock the required `utils` functions if running locally
5562 const { failBuild, show } = getUtils ( { utils } ) ;
5663
0 commit comments