diff --git a/js/live-reload.js b/js/live-reload.js deleted file mode 100644 index 76e5604..0000000 --- a/js/live-reload.js +++ /dev/null @@ -1,5 +0,0 @@ -const init = () =>{ - websocket = new WebSocket("ws://"+window.location.host+"/websocket"); - websocket.onmessage = (e) => location.reload(); -} -window.addEventListener("load", init, false); diff --git a/src/App.fsproj b/src/App.fsproj index 1e436e5..908b963 100644 --- a/src/App.fsproj +++ b/src/App.fsproj @@ -8,11 +8,13 @@ + + diff --git a/src/Dev.fs b/src/Dev.fs new file mode 100644 index 0000000..c2b120a --- /dev/null +++ b/src/Dev.fs @@ -0,0 +1,10 @@ +module Dev + +open Browser.Dom +open Browser.WebSocket + +let private init _ = + let ws = WebSocket.Create $"ws://{window.location.host}/websocket" + ws.onmessage <- fun _ -> window.location.reload () + +window.addEventListener ("load", init) diff --git a/src/Generator.fs b/src/Generator.fs index 884b3fa..1fb48d6 100644 --- a/src/Generator.fs +++ b/src/Generator.fs @@ -581,8 +581,7 @@ let render (opts: RnderOptions) = let devInjection, devScript = match opts.stage with - | Development -> - Some("/js/live-reload.js"), [ ("js/live-reload.js", $"{opts.dst}{opts.pathRoot}/js/live-reload.js") ] + | Development -> Some("/js/dev.js"), [ ("src/Dev.fs.js", $"{opts.dst}{opts.pathRoot}/js/dev.js") ] | Production -> None, [] let site: FixedSiteContent =