Giving up on Eleventy Dev Server in Production
After zachleat himself begged me to stop doing it, I’ve moved away from running the Eleventy’s development server in production. What this means is:
-
No more fancy live-reloading when I edit a page and someone happens to be on it.
- This was somewhat buggy anyway? It would often kick people to the top of the page.
- I’m probably more safe from vulnerabilites that might exist if one were to run a development server in production, which is something that the maintainers would not be accounting for, because who would run their development server in production.
- I had to write my own live-reload server thingy.
Here you go:
import { watch } from 'node:fs';
import { execSync } from 'node:child_process';
let cooldown = false;
console.info("watching your garden...");
watch('.', { recursive: true, ignore: ["_site/**", "_site/**/.*"] },
(change, filename) => {
if (cooldown) return;
cooldown = true;
console.info(`${filename ?? "???"} was changed!!`);
setTimeout(() => {
cooldown = false;
execSync('npx @11ty/eleventy', { stdio: 'inherit' }, (err) => {
if (err) {
console.error(`Error: ${err.message}`);
return;
} else {
console.info("ran 11ty :)");
}
})
}, 200);
}
);
update: this broke sorting somehow???
update 2: seems like @11ty/eleventy –watch would work here instead
Last updated: Nov 10, 2026 ()