Skip to content

Commit

Permalink
add base url to build config
Browse files Browse the repository at this point in the history
Signed-off-by: Teo Koon Peng <teokoonpeng@gmail.com>
  • Loading branch information
koonpeng committed Aug 5, 2024
1 parent 2803ced commit 535c3d6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/dashboard/app-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
},
"cartIds": [],
"buildConfig": {
"baseUrl": "/",
"authProvider": "stub",
"customTabs": false,
"adminTab": false
Expand Down
1 change: 1 addition & 0 deletions packages/dashboard/src/app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions packages/dashboard/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="vite/client" />

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;
9 changes: 6 additions & 3 deletions packages/dashboard/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 535c3d6

Please sign in to comment.