🎭 Adds environment variables for modes

This commit is contained in:
Rune Harlyk
2024-02-25 01:51:55 +01:00
committed by Rune Harlyk
parent 0f676e3543
commit 3e7918208a
10 changed files with 43 additions and 14 deletions
+9 -6
View File
@@ -1,8 +1,11 @@
const forWeb = import.meta.env.MODE === 'WEB';
const mock = import.meta.env.MODE === 'MOCK';
export const webAppBuild = import.meta.env.MODE === 'WEB';
export const hostname = window.location.hostname;
export const location = mock ? `${window.location.hostname}:2096` : 'leika.local';
export const isSecure = window.location.protocol === 'https:';
export const socketLocation = forWeb
? `wss://${window.location.hostname}:2096`
: `ws://${location}`;
export const location = import.meta.env.VITE_API_URL.replace('hostname', hostname);
const socketScheme = isSecure ? 'wss://' : 'ws://';
export const socketLocation =
socketScheme + import.meta.env.VITE_SOCKET_URL.replace('hostname', hostname);
@@ -1,5 +1,7 @@
import { writable } from 'svelte/store';
export const isEmbeddedApp = import.meta.env.VITE_EMBEDDED_BUILD === 'true';
export const persistentStore = (key: string, initialValue: any) => {
const savedValue = JSON.parse(localStorage.getItem(key) as string);
const data = savedValue !== null ? savedValue : initialValue;