-
-
Notifications
You must be signed in to change notification settings - Fork 495
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
Add beforeBuild
and afterBuild
events
#1143
Conversation
Would be nice to have this to avoid being depend on gulp or other build tools. But it seems that the promise ( For example in watch I have I did had time to investigated yet but wanted to report. |
Thank you! |
@georges-gomes seems ok here? |
Can't reproduce. Looks good thanks 👍 |
Hey everyone, I'm currently trying to build some functionality using the Maybe the afterBuild event should receive an argument with information on the finished build (the output directory would suffice, actually)? Is that even possible? Or is there a better approach to write some reusable functionality that is guaranteed to run after every other file has been generated (this is why I can't just use a normal template) and has access to the build directory? |
The way I understand it you define your afterBuild event inside your (Untested) example code cobbled together from snippets in the documentation: module.exports = function(eleventyConfig) {
let myConfig = {
dir: {
output: "_my_site_dir"
}
};
eleventyConfig.on('afterBuild', () => {
console.log('You can now work on', myConfig.dir.output);
});
return myConfig;
}; I don't know how you'd figure out the output directory if you stick to the default. It's defined as |
@lasar Thanks! That will definitely work in a project setting. But what about plugins? Each plugin has it's own |
I'm also struggling with the use of I agree, the output dir is quite important for a Another challenge for the use of @zachleat what would be the perfect way to create these "pre-build" and "post-build" synchronous "hooks" ? I really want them, I can contribute, but I don't want to waist my time (and yours :D) going in the wrong direction. |
@MoritzLost @georges-gomes I'd suggest to fill a new issue with these requests. |
Swapping to ship this with 0.11.1. We’ll look a little closer at running async/sync hooks with 1.0. Some work for this has been completed at #1359 if you’d like to follow along there! |
Awesome, thanks @zachleat subscribed |
While looking for a way to run code after a build has completed, either from watch or from a normal build, I came across
beforeWatch
code in the codebase. This extends that pattern to outputbeforeBuild
andafterBuild
events, too. Usecase forafterBuild
is to trigger events only after Eleventy has run, for instance live reloading from a third-party server, or building a search index.I'm also going to make a corresponding PR 11ty-website to document this functionality and
beforeWatch
(#1042)