diff --git a/src/renderer/managers/plugins.ts b/src/renderer/managers/plugins.ts index f2534400e..4c41876ca 100644 --- a/src/renderer/managers/plugins.ts +++ b/src/renderer/managers/plugins.ts @@ -86,22 +86,21 @@ export async function start(id: string): Promise { ); plugin.exports = pluginExports; await pluginExports.start?.(); + if (plugin.hasCSS) { + if (styleElements.has(plugin.manifest.id)) { + // Remove old style element in case it wasn't removed properly + styleElements.get(plugin.manifest.id)?.remove(); + } + + const el = loadStyleSheet( + `replugged://plugin/${plugin.path}/${plugin.manifest.renderer?.replace(/\.js$/, ".css")}`, + ); + styleElements.set(plugin.manifest.id, el); + } })(), ]); } - if (plugin.hasCSS) { - if (styleElements.has(plugin.manifest.id)) { - // Remove old style element in case it wasn't removed properly - styleElements.get(plugin.manifest.id)?.remove(); - } - - const el = loadStyleSheet( - `replugged://plugin/${plugin.path}/${plugin.manifest.renderer?.replace(/\.js$/, ".css")}`, - ); - styleElements.set(plugin.manifest.id, el); - } - running.add(plugin.manifest.id); logger.log(`Plugin started: ${plugin.manifest.name}`); } catch (e: unknown) {