angyvolin / gulp-penthouse

Gulp plugin for extracting critical path css
MIT License
17 stars 8 forks source link

Critical css is not generating #9

Open vingauta opened 3 years ago

vingauta commented 3 years ago

Team,

I am facing issue while generating critical css. Plugin is returning some sort of reset css instead of actual page related css. It was working fine few months back with same configuration what we currently have. Here is my code

promiseArray.push(new Promise((resolve, reject) => { gulp.src(criticalContactCss) .pipe(gulpPenthouse({ url: url, width: width, height: height, renderWaitTime: 3000, pageLoadSkipTimeout: 300000, timeout: 900000, forceInclude: [], forceExclude: [] })) .pipe(concat("critical" + templateName + ".css")) .pipe(require("gulp-clean-css")()) .pipe(gulp.dest(outputPath)) .on("end", resolve) .on("error",reject) }));

Can you please help on this?

Thanks Vinant

vingauta commented 3 years ago

Hi Team,

Any update?

Thanks Vinant

amaragain commented 3 years ago

Hi Vinant,

There is no userAgent defined in the configuration. So the module uses the default userAgent - GoogleBot Desktop.

If the userAgent is deprecated or not supported or if Google Bot is being blocked by the application, Critical CSS will not get generated.

So try specifying a different userAgent in the config, like Google Chrome - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36

gulpPenthouse({ url: url, width: width, height: height, renderWaitTime: 3000, pageLoadSkipTimeout: 300000, timeout: 900000, forceInclude: [], forceExclude: [], userAgent: newUserAgent }