Fix: normalize chokidar paths for hot reload on Windows

Hot reload was not updating pages when editing Markdown files inside subfolders on Windows only.
The issue was caused by inconsistent path separators from chokidar.
This patch ensures paths are normalized with toPosixPath before rebuild.
This commit is contained in:
Giuseppe Alfieri 2025-09-07 14:58:26 +02:00 committed by GitHub
parent 42052ebb5f
commit 93f76d7978
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -151,16 +151,19 @@ async function startWatching(
const changes: ChangeEvent[] = [] const changes: ChangeEvent[] = []
watcher watcher
.on("add", (fp) => { .on("add", (fp) => {
fp = toPosixPath(fp)
if (buildData.ignored(fp)) return if (buildData.ignored(fp)) return
changes.push({ path: fp as FilePath, type: "add" }) changes.push({ path: fp as FilePath, type: "add" })
void rebuild(changes, clientRefresh, buildData) void rebuild(changes, clientRefresh, buildData)
}) })
.on("change", (fp) => { .on("change", (fp) => {
fp = toPosixPath(fp)
if (buildData.ignored(fp)) return if (buildData.ignored(fp)) return
changes.push({ path: fp as FilePath, type: "change" }) changes.push({ path: fp as FilePath, type: "change" })
void rebuild(changes, clientRefresh, buildData) void rebuild(changes, clientRefresh, buildData)
}) })
.on("unlink", (fp) => { .on("unlink", (fp) => {
fp = toPosixPath(fp)
if (buildData.ignored(fp)) return if (buildData.ignored(fp)) return
changes.push({ path: fp as FilePath, type: "delete" }) changes.push({ path: fp as FilePath, type: "delete" })
void rebuild(changes, clientRefresh, buildData) void rebuild(changes, clientRefresh, buildData)