feat(dev): add hot-realoding proxy dev server on :30001

This commit is contained in:
Konstantin Chernyshev 2025-09-02 19:13:31 +02:00
parent 1b9defe4ad
commit ddb4c29252
7 changed files with 315 additions and 40 deletions

View file

@ -171,6 +171,26 @@ Hooks.on('ready', async () => {
}
runMigrations();
// Development live-reload: connect to local WS server if available
try {
const defaultPort = 30123;
const storedPort = Number(localStorage.getItem('DH_DEV_RELOAD_PORT'));
const port = Number.isFinite(storedPort) ? storedPort : defaultPort;
const ws = new WebSocket(`ws://localhost:${port}`);
let reloadTimer;
ws.onmessage = () => {
// Debounce rapid changes
clearTimeout(reloadTimer);
reloadTimer = setTimeout(() => {
window.location.reload();
}, 100);
};
ws.onerror = () => {};
ws.onclose = () => {};
} catch (err) {
// Ignore if WebSocket is not available or blocked
}
});
Hooks.once('dicesoniceready', () => {});