eleventy: Trigger builds programmatically via JavaScript API without the cli
Is it possible to trigger a build via JavaScript without using the cli (i.e. npx eleventy
)?
I’ve wrapped Eleventy in an Electron application, I would like to trigger new builds on button click, after updating data via form entry–but I’m not sure how to trigger builds via API without running the cli.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 17
- Comments: 17 (11 by maintainers)
If you do build a normal API, it would be really nice if 11ty could produce a stream that can be consumed by Gulp. As it stands, one must built to a temp directory first…
I did post a quick example of this here https://twitter.com/zachleat/status/1167115558552244226 but work is ongoing here for something official
So @zachleat has this example here:
https://gist.github.com/zachleat/5b5ae0ddadbeba6169f18e5b4aa58a66
Problem is, AFAICT, that the config still comes from a
.js
file.https://github.com/11ty/eleventy/blob/master/src/Eleventy.js#L30
In a cloud function this could be a problem since you may need to determine paths dynamically at runtime.
Is there a way to pass the config to the
Eleventy
constructor instead?I came here to request this feature so that I can use the step-through debugger.
This isn’t a very ergonomic solution, as I want to be able to just
require()
the package and be done. Would a pull request for this functionality be welcome?First draft of the docs for this feature are available: https://www.11ty.dev/docs/programmatic/
Note that 1.0 will have this functionality too. https://twitter.com/zachleat/status/1358966988203323394
Subscribe to https://github.com/11ty/eleventy/pull/1629
I hadn’t looked at it yet, but I think you’re right that it could potentially have what I need. Thanks! If I’m able to trigger builds with some of that code, I’ll post an update.