Get rid of livereload dependency. Draft Baroque (still some issues)
[xogo.git] / server.js
index e08d13b..06d9866 100644 (file)
--- a/server.js
+++ b/server.js
@@ -55,7 +55,13 @@ wss.on("connection", (socket, req) => {
   sockets[sid] = socket;
   socket.isAlive = true;
   socket.on("pong", () => socket.isAlive = true);
-
+  if (params.dev == true) {
+    const chokidar = require("chokidar");
+    const watcher = chokidar.watch(
+      ["*.js", "*.css", "utils/", "variants/"],
+      {persistent: true});
+    watcher.on("change", path => send(sid, "filechange", {path: path}));
+  }
   socket.on("message", (msg) => {
     const obj = JSON.parse(msg);
     switch (obj.code) {