From fc2406eea4ba425941cbd5d6cd781cccc04f5df7 Mon Sep 17 00:00:00 2001 From: BurnyLlama Date: Mon, 6 Mar 2023 10:20:47 +0100 Subject: [PATCH] Fixed crash on SCSS error. --- dev.js | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/dev.js b/dev.js index d36842b..fefea47 100644 --- a/dev.js +++ b/dev.js @@ -20,26 +20,31 @@ njk.configure( chokidar.watch("./src").on("change", () => { console.log("Detected changes in SCSS! Recompiling...") - const { css } = sass.compile( - "./src/main.scss", - { - sourceMap: false, - alertColor: true, - style: "compressed" - } - ) + try { + const { css } = sass.compile( + "./src/main.scss", + { + sourceMap: false, + alertColor: true, + style: "compressed" + } + ) - console.log("Compile done! Saving changes...") + console.log("Compile done! Saving changes...") - if (!fs.existsSync("./out")) - fs.mkdirSync("./out") + if (!fs.existsSync("./out")) + fs.mkdirSync("./out") - fs.writeFileSync( - "./out/main.css", - css - ) + fs.writeFileSync( + "./out/main.css", + css + ) - console.log("Saved!") + console.log("Saved!") + } catch (error) { + console.log("Error while compiling!") + console.error(error) + } }) server.use("/assets", express.static("./out"))