I am trying to implement this module for my site (10.3.10) and am hoping to use the recommended critical package from addyosmani. However, I can't figure out how to actually configure the package to generate the critical CSS files from my Drupal site. I am building the tooling in gulp. Here's what I have so far:
// FYI: vars.dist_directory is an imported variable w/ path information.
gulp.task('critical', () => {
import("critical").then((critical)=>{
critical.generate({
base: vars.dist_directory,
src: 'index.html',
target: vars.dist_directory + "css",
width: 1300,
height: 900,
});
});
The blocker right now is what I should put for the src property. The error I'm getting is "Error: File not found: static/assets/index.html", which makes sense as it doesn't exist. What do I use to make this work for a Drupal site?
Comments
Comment #2
flyke commentedFor src, you use the url of the page you wish to create critical css for.
For me, its my front page. Since my local version runs on ddev I enter my ddev site url there.
I don't use gulp but npm/webpack. I have a
scripts/generate-critical.jsthat looks like this:And in my package.json I have a script:
Which I run with:
ddev npm run criticalcss