aboutsummaryrefslogtreecommitdiff
path: root/src/preload.ts
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2023-01-14 02:15:17 +0100
committerVendicated <vendicated@riseup.net>2023-01-14 02:15:17 +0100
commitfd766bc98f96f4b13b00bca9b9e818f20d1aa367 (patch)
treed81c79b5ca1ca835d18134de5ff649aa750f4036 /src/preload.ts
parent0e5b8b07c99f3ab54c576a58ac3f59721d4f9904 (diff)
downloadVencord-fd766bc98f96f4b13b00bca9b9e818f20d1aa367.tar.gz
Vencord-fd766bc98f96f4b13b00bca9b9e818f20d1aa367.tar.bz2
Vencord-fd766bc98f96f4b13b00bca9b9e818f20d1aa367.zip
Dev: Hot reload core css
Diffstat (limited to 'src/preload.ts')
-rw-r--r--src/preload.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/preload.ts b/src/preload.ts
index ee2fb80..33f2410 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;