From 535c3d6492737cb6b33f751fd95f42c3873ff3c9 Mon Sep 17 00:00:00 2001 From: Teo Koon Peng Date: Mon, 5 Aug 2024 04:24:19 +0000 Subject: [PATCH] add base url to build config Signed-off-by: Teo Koon Peng --- packages/dashboard/app-config.json | 1 + packages/dashboard/src/app-config.ts | 1 + packages/dashboard/src/vite-env.d.ts | 1 + packages/dashboard/vite.config.ts | 9 ++++++--- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/dashboard/app-config.json b/packages/dashboard/app-config.json index 5996e8a2a..7397b8dfe 100644 --- a/packages/dashboard/app-config.json +++ b/packages/dashboard/app-config.json @@ -33,6 +33,7 @@ }, "cartIds": [], "buildConfig": { + "baseUrl": "/", "authProvider": "stub", "customTabs": false, "adminTab": false diff --git a/packages/dashboard/src/app-config.ts b/packages/dashboard/src/app-config.ts index 3fd23087b..43fecdaed 100644 --- a/packages/dashboard/src/app-config.ts +++ b/packages/dashboard/src/app-config.ts @@ -56,6 +56,7 @@ export interface RuntimeConfig { // these will be injected as defines and potentially be tree shaken out export interface BuildConfig { + baseUrl: string; authProvider: 'keycloak' | 'stub'; customTabs?: boolean; adminTab?: boolean; diff --git a/packages/dashboard/src/vite-env.d.ts b/packages/dashboard/src/vite-env.d.ts index 9423c80a2..9e2cf726b 100644 --- a/packages/dashboard/src/vite-env.d.ts +++ b/packages/dashboard/src/vite-env.d.ts @@ -1,5 +1,6 @@ /// +declare const APP_CONFIG_BASE_URL: string; declare const APP_CONFIG_AUTH_PROVIDER: string; declare const APP_CONFIG_ENABLE_CUSTOM_TABS: boolean; declare const APP_CONFIG_ENABLE_ADMIN_TAB: boolean; diff --git a/packages/dashboard/vite.config.ts b/packages/dashboard/vite.config.ts index 78f5fe393..6cc10bff3 100644 --- a/packages/dashboard/vite.config.ts +++ b/packages/dashboard/vite.config.ts @@ -39,12 +39,15 @@ function booleanToString(b: boolean | null | undefined) { return b ? 'true' : 'false'; } +const buildConfig = appConfig.buildConfig; + // https://vitejs.dev/config/ export default defineConfig({ + base: buildConfig.baseUrl, define: { - APP_CONFIG_AUTH_PROVIDER: `'${appConfig.buildConfig.authProvider}'`, - APP_CONFIG_ENABLE_CUSTOM_TABS: `${booleanToString(appConfig.buildConfig.customTabs)}`, - APP_CONFIG_ENABLE_ADMIN_TAB: `${booleanToString(appConfig.buildConfig.adminTab)}`, + APP_CONFIG_AUTH_PROVIDER: `'${buildConfig.authProvider}'`, + APP_CONFIG_ENABLE_CUSTOM_TABS: `${booleanToString(buildConfig.customTabs)}`, + APP_CONFIG_ENABLE_ADMIN_TAB: `${booleanToString(buildConfig.adminTab)}`, }, plugins: [injectGlobals, react()], test: {