feat(dev): add simple live reloading

This commit is contained in:
2021-03-13 01:31:32 +01:00
parent 74e8c5bb83
commit ab894e9709
11 changed files with 169 additions and 280 deletions

View File

@ -4,4 +4,18 @@ const app = new App({
target: document.body
});
//@ts-ignore
if (IS_DEV) {
let ws, int;
const connect = () => {
if (ws) ws.close();
//@ts-ignore
ws = new WebSocket("ws://localhost:" + PORT + "/ws")
ws.onclose = () => !int && (int = setInterval(connect, 1000))
ws.onopen = () => { clearInterval(int); (int = false); console.log("dev ws open") };
ws.onmessage = () => window.location.reload();
}
connect();
}
export default app;