Dev: Hot reload core css

This commit is contained in:
Vendicated 2023-01-14 02:15:17 +01:00
parent 0e5b8b07c9
commit fd766bc98f
No known key found for this signature in database
GPG key ID: A1DC0CFB5615D905

View file

@ -19,7 +19,7 @@
import { debounce } from "@utils/debounce"; import { debounce } from "@utils/debounce";
import IpcEvents from "@utils/IpcEvents"; import IpcEvents from "@utils/IpcEvents";
import { contextBridge, ipcRenderer, webFrame } from "electron"; import { contextBridge, ipcRenderer, webFrame } from "electron";
import { readFileSync } from "fs"; import { readFileSync, watch } from "fs";
import { join } from "path"; import { join } from "path";
import VencordNative from "./VencordNative"; import VencordNative from "./VencordNative";
@ -48,6 +48,11 @@ if (location.protocol !== "data:") {
try { try {
const css = readFileSync(rendererCss, "utf-8"); const css = readFileSync(rendererCss, "utf-8");
insertCss(css); insertCss(css);
if (IS_DEV) {
watch(rendererCss, debounce(() => {
document.getElementById("vencord-css-core")!.textContent = readFileSync(rendererCss, "utf-8");
}, 30));
}
} catch (err) { } catch (err) {
if ((err as NodeJS.ErrnoException)?.code !== "ENOENT") if ((err as NodeJS.ErrnoException)?.code !== "ENOENT")
throw err; throw err;