From 6f42305770c8373f044fe1495f6a0d283e79a903 Mon Sep 17 00:00:00 2001 From: Oliwia Gowor Date: Fri, 27 Sep 2024 11:36:55 +0200 Subject: [PATCH] fix: adjust theme url for vite --- src/state/preferences/themeAtom.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/state/preferences/themeAtom.ts b/src/state/preferences/themeAtom.ts index 3dd64c280b..deec836be7 100644 --- a/src/state/preferences/themeAtom.ts +++ b/src/state/preferences/themeAtom.ts @@ -54,9 +54,12 @@ function addLinkNode() { } type AddLinkEffect = () => AtomEffect; export const addLinkEffect: AddLinkEffect = () => ({ onSet, setSelf }) => { + const envUrl = + import.meta.env.BASE_URL === '/' ? '' : import.meta.env.BASE_URL; + setSelf(param => { const defaultValue = param as Theme; - applyThemeToLinkNode(defaultValue, import.meta.env.BASE_URL); + applyThemeToLinkNode(defaultValue, envUrl); return defaultValue; }); @@ -65,7 +68,7 @@ export const addLinkEffect: AddLinkEffect = () => ({ onSet, setSelf }) => { if (newTheme === 'light_dark') themeNew = isSystemThemeDark() ? 'dark' : 'default'; else themeNew = newTheme === 'sap_horizon' ? 'default' : newTheme.slice(12); - applyThemeToLinkNode(themeNew, import.meta.env.BASE_URL); + applyThemeToLinkNode(themeNew, envUrl); }); };