From fd766bc98f96f4b13b00bca9b9e818f20d1aa367 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 14 Jan 2023 02:15:17 +0100 Subject: [PATCH] Dev: Hot reload core css --- src/preload.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/preload.ts b/src/preload.ts index ee2fb80d..33f2410b 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -19,7 +19,7 @@ import { debounce } from "@utils/debounce"; import IpcEvents from "@utils/IpcEvents"; import { contextBridge, ipcRenderer, webFrame } from "electron"; -import { readFileSync } from "fs"; +import { readFileSync, watch } from "fs"; import { join } from "path"; import VencordNative from "./VencordNative"; @@ -48,6 +48,11 @@ if (location.protocol !== "data:") { try { const css = readFileSync(rendererCss, "utf-8"); insertCss(css); + if (IS_DEV) { + watch(rendererCss, debounce(() => { + document.getElementById("vencord-css-core")!.textContent = readFileSync(rendererCss, "utf-8"); + }, 30)); + } } catch (err) { if ((err as NodeJS.ErrnoException)?.code !== "ENOENT") throw err;