fix(bgm): hot-reload markdown definition edits

Normalize the games root to POSIX separators so the HMR path guard
matches on Windows, and watch the real on-disk markdown files (which
defMap.files omits in favor of their virtual code blocks) so edits
trigger a re-collect instead of a manual restart.
This commit is contained in:
2026-08-10 00:06:43 +08:00
parent c5d6dff12d
commit 90baa35c7c
2 changed files with 18 additions and 4 deletions
+4 -1
View File
@@ -85,10 +85,13 @@ describe('bgm vite plugin', () => {
(plugin.buildStart as Callable<typeof plugin.buildStart>).call(context, {} as never);
// Every def file (real + virtual code blocks) is watched so edits
// trigger a re-collect.
// trigger a re-collect. The real markdown source must be watched too:
// `defMap.files` only lists virtual code-block files, so without watching
// the on-disk `.md` file the dev server would never notice an edit.
expect(watched.length).toBeGreaterThan(0);
expect(watched.some((f) => f.endsWith('.yaml'))).toBe(true);
expect(watched.some((f) => f.endsWith('.csv'))).toBe(true);
expect(watched.some((f) => f.endsWith('.md'))).toBe(true);
expect(watched.every((f) => path.isAbsolute(f))).toBe(true);
});
});