Fixed crash on SCSS error.

This commit is contained in:
BurnyLlama 2023-03-06 10:20:47 +01:00
parent 2eaa38c955
commit fc2406eea4

37
dev.js
View File

@ -20,26 +20,31 @@ njk.configure(
chokidar.watch("./src").on("change", () => { chokidar.watch("./src").on("change", () => {
console.log("Detected changes in SCSS! Recompiling...") console.log("Detected changes in SCSS! Recompiling...")
const { css } = sass.compile( try {
"./src/main.scss", const { css } = sass.compile(
{ "./src/main.scss",
sourceMap: false, {
alertColor: true, sourceMap: false,
style: "compressed" alertColor: true,
} style: "compressed"
) }
)
console.log("Compile done! Saving changes...") console.log("Compile done! Saving changes...")
if (!fs.existsSync("./out")) if (!fs.existsSync("./out"))
fs.mkdirSync("./out") fs.mkdirSync("./out")
fs.writeFileSync( fs.writeFileSync(
"./out/main.css", "./out/main.css",
css css
) )
console.log("Saved!") console.log("Saved!")
} catch (error) {
console.log("Error while compiling!")
console.error(error)
}
}) })
server.use("/assets", express.static("./out")) server.use("/assets", express.static("./out"))