-
-
Notifications
You must be signed in to change notification settings - Fork 496
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 support for a "cool-down" period before triggering a regeneration. #559
Comments
are you running the gulp tasks in a series or parallel ? Seems you should be able to control it there unless I'm misunderstanding. |
Both gulp and eleventy are running in parallel using the following npm scripts: "scripts": {
"dev": "npm-run-all --parallel dev:eleventy dev:gulp",
"dev:eleventy": "eleventy --serve",
"dev:gulp": "gulp"
} Both |
untested
in theory that will run the gulp task first, then eleventy which I think is what you were asking. |
You can't run them in series. Gulp is being run in watch mode (watching for changes) so it never exits and series waits until the first task exits before running the second. If I don't run gulp in watch mode then it won't recompile scss changes. And the same is true for eleventy. Its running in watch mode and never exits because its running the local test web server. |
Gotcha. Sorry for misunderstanding your configuration. |
I have this same problem with my 11ty tailwind starter. PostCSS is watching and rebuilding the CSS and Eleventy Serve is watching the *.md but the problem imho is that 11ty blocks the command execution chain. The only solutions I could think of both involved relying on only one of the processes to do all of the watching and rebuilding:
|
Here is how I’m using Gulp with Jekyll to watch files https://github.com/miklb/jekyll-indieweb/blob/b313ce907b03eb34d59164eaef60bf3fc03fa90f/gulpfile.js#L78 I also use Gulp to run Jekyll which I’m sure could be adapted for Eleventy . Not saying it’s the most elegant solution however |
Some discussion for this is also happening at the PR: #564 |
@danfascia, re: option 2, making gulp to everything could potentially work, but since I'm using eleventy as the web server I would have to have an instance of eleventy running as the server (and not processing any files) and a second instance executed by gulp whenever any input files change. And then I would need to go through all the work of duplicating a bunch of eleventy config into gulp in order to make sure it was watching the same files in the same places as eleventy already is. @miklb, the reason that this works is that you're manually running browserSync and the thing that watches the files (gulp in this case). In the eleventy case, Additionally, it looks like you have a bug in your script here (https://github.com/miklb/jekyll-indieweb/blob/b313ce907b03eb34d59164eaef60bf3fc03fa90f/gulpfile.js#L81) where this line is calling |
@veleek yes actually you're right, the fact that 11ty is also the webserver scuppers it. However in my 11ty starter I use lightserver as the webserver instead of the built in one since it is nice to decouple processes. I feel like you have to do it one of 2 ways ...
It's the only way you can not block the render chain with eleventy --serve |
Just adding my 2 cents here.
When using Gulp, I generally make it watch Here is a simple .gulpfile as an example. |
Thanks @jeromecoupe. I tried switching over to a similar gulpfile and everything seems to be working well (after working around a few issues with childprocess on Windows; the I'm pretty happy with this solution so I'll probably keep it, but I approve of having the cool-down period in eleventy even if it's only useful for the small subset of people who might only use eleventy and not any other external build tool. |
Sure @veleek, sorry if I came across as not supporting the feature request. Was just detailing an approach that would sidestep the need for a delay. |
:) No worries, that's not what I thought you were trying to do. I just wish I'd know how easy it was to do it your way before! |
As a side note, setting the shell option to true with const cp = require("child_process");
// Eleventy
function eleventyBuild() {
return cp.spawn("npx", ["eleventy", "--quiet"], {
stdio: "inherit", shell: true
});
} |
Aaaaaah, so THAT'S how you do it! Thanks. |
Note also that this was included to solve a few problems in |
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:
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.The text was updated successfully, but these errors were encountered: