Skip to content

Commit

Permalink
Register dependencies found during pug compilation
Browse files Browse the repository at this point in the history
My main layout is written in pug, and uses an `include` file. When
running `eleventy --serve` I noticed that changes to the included file
would trigger rebuilds, but not show the changes. This seems to be
similar to #2741.

Here I fix this by using the list of dependencies that the pug `compile`
function includes on the function that it returns. With this I am seeing
changes to my included file reflected immediately.
  • Loading branch information
aschrab committed Sep 29, 2023
1 parent ecd0579 commit e50438d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Engines/Pug.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ class Pug extends TemplateEngine {
options.filename = inputPath;
}

return this.pugLib.compile(str, options);
const compiled = this.pugLib.compile(str, options);

if (compiled.dependencies) {
this.config.uses.addDependency(inputPath, compiled.dependencies);
}

return compiled;
}
}

Expand Down

0 comments on commit e50438d

Please sign in to comment.