Closed MaybeThisIsRu closed 2 years ago
Could you give any indication on how to call the reload function in the gulp.babel.js
file? I gave this an attempt but it actually left me quite puzzling... Also, what should the reload function return?
Although the PR has been approved and merged, it has not yet made it into an official Eleventy release. It's targeted for v1; see milestone details here, you'll find the #1126 PR as a part of this milestone.
So we still don't have any control over the BrowserSync instance until Eleventy v1 is released.
This should have been doable with something like...
// Reload after asset tasks finish running etc.
function reload() {
const server = browserSync.get("eleventy-server");
if (server)
server.reload();
}
And adding it to the task series:
function cssWatcher() {
return watch(
[`${paths.css.src}/**/*.css`, ...paths.css.additionalWatch],
series(css, reload)
);
}
That does not seem to work:
[23:10:05] Error: An instance with the name `eleventy-server` was not found.
at Function.get (/Users/____/Code/smix-eleventy-starter/node_modules/browser-sync/lib/index.js:45:11)
at reload (/Users/____/Code/smix-eleventy-starter/gulp_tasks/eleventy.babel.js:20:29)
at bound (node:domain:421:15)
at runBound (node:domain:432:12)
at asyncRunner (/Users/____/Code/smix-eleventy-starter/node_modules/async-done/index.js:55:18)
at processTicksAndRejections (node:internal/process/task_queues:78:11)
^ And that's because I haven't yet locally updated to Eleventy 1.0. 🤦🏻♀️😬
...and it still fails. Hmm.
Might be because Eleventy is run as a child process?
I probably don't have the bandwidth for this. The time and headache that will sink into this is not worth it. Manual reloads ftw. :(
From the README:
This PR has been approved and merged in by Zach. We can finally plug in to Eleventy's server and trigger a reload when our CSS or JS tasks finish (or any other). :)