feat(dev): add simple live reloading
This commit is contained in:
@ -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;
|
Reference in New Issue
Block a user