New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eleventy.before callback runs after ignores are processed #2207
Comments
See issue #1488 for another instance of |
Quick note since I was looking at the docs for this earlier today, but it appears that the
-eleventyConfig.on("beforeBuild", function () {
+eleventyConfig.on('eleventy.before', async () => { |
Thank you @pdehaan for pointing that out. The problem is persistent with the new label and I have updated the example repository to reflect this. |
Yep, can confirm on v1.0.0 that calling eleventyConfig.ignores.add("ignore.md"); // WORKS
eleventyConfig.on("eleventy.before", function () {
eleventyConfig.ignores.add("ignore.md"); // DOESNT WORK
}); |
Yeah, I've used that as a work-around in my Eleventy ignore plugin: updateIgnores();
eleventyConfig.on("eleventy.before", updateIgnores); |
Sorry, I misspoke a bit there (stand by 😅) |
Hmmmmmm. Configuration is the very first thing that happens, before anything else. It is needed in various constructors in the code (for good or bad, see #2103). So, to be clear the However, a couple of things conspired here to cause this problem:
I agree that it would be best to have Specifically, this is how the I think as a stop-gap we can add an additional event (maybe |
It was originally added as an async mechanism to modify configuration in synchronous config callbacks. module.exports = function (eleventyConfig) {
eleventyConfig.on("eleventy.beforeConfig", async function (eleventyConfig) {
// You can do async things in here too
eleventyConfig.ignores.add("ignore.md");
});
}; |
Describe the bug
If a callback is added to the
eleventy.before
event, that callback is executed after Eleventy has already processed theeleventyConfig.ignores
set.To Reproduce
Create a template
ignore.md
.Add callback on
eleventy.before
event which adds template's path toignores
.Build the site.
The template will be rendered.
If
eleventy --serve
is used, then the template will be ignored on subsequent rebuilds.Here is a simple repo that reproduces the behavior: https://github.com/TheDocTrier/eleventy-before-build-ignore
Expected behavior
The
eleventy.before
callbacks are run before Eleventy processes the ignores set such that modifications to it are reflected in the build.Environment:
Edit
Update issue and example to use
eleventy.before
instead of the deprecatedbeforeBuild
.The text was updated successfully, but these errors were encountered: