eleventy: Add support for a "cool-down" period before triggering a regeneration.

I have a site which contains multiple uniquely styled sub-pages which each have their own SASS files. When running eleventy alongside gulp, when I save a single SASS file, gulp regenerates all of the css files which triggers eleventy to regenerate. Unfortunately, the first file change triggers a regeneration, and the second file change queues up another one. So as any css file causes eleventy to regenerate everything twice which really slows down iteration.

For example, given this super basic site example:

/site
    /events
        /birthday
            index.md
            style.scss
            /media
                thing.ttf, etc.
        /christmas
            index.md
            style.scss
            etc.

I have a gulp task that processes all the .scss files to produce style.css in the same folder. The actual sub-sections are relatively complicated but self-contained and they include things like fonts, images, additional sub-pages etc. Moving all the styles and images to folders outside of the root site would make it difficult to manage each of these sites independently so I would like to keep everything self-contained if possible.

I would love if there was some sort of configurable delay that would wait after receiving a file modification event before regenerating the site. The more complex version would be don’t regenerate until X ms after the last file change event, so if my gulp task is long running each generated file would keep pushing back the regeneration time a little bit until everything was done.

This is similar to the awaitWriteFinish property in chokidar which I manually enabled in Eleventy.js and was hoping would work by queuing up file change events quickly enough to cause only a single eleventy rebuild, but no luck.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

Just adding my 2 cents here.

  • I never run Eleventy in watch mode when using Gulp or NPM scripts
  • IMHO, when using a build tool, that build tool should orchestrate everything (file generation and server / browsersync)
  • in this case it should watch files and run Eleventy when appropriate

When using Gulp, I generally make it watch njk and md files and use child process to run Eleventy. That way, you can control pretty much everything in terms of tasks and subtasks order.

Here is a simple .gulpfile as an example.

Gotcha. Sorry for misunderstanding your configuration.