-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathappConfig.ts
More file actions
38 lines (33 loc) · 838 Bytes
/
appConfig.ts
File metadata and controls
38 lines (33 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import type { AppConfig, AppExport } from './types.js';
const defaultAppConfig: AppConfig = {
app: {
strict: false,
rootId: 'ice-container',
},
router: {
type: 'browser',
fallbackElement: null,
},
};
export default function getAppConfig(appExport: AppExport): AppConfig {
const appConfig = appExport?.default || {};
const { app, router, ...others } = appConfig;
return {
app: {
...defaultAppConfig.app,
...(app || {}),
},
router: {
...defaultAppConfig.router,
...(router || {}),
},
...others,
};
}
export function defineAppConfig(appConfigOrDefineAppConfig: AppConfig | (() => AppConfig)): AppConfig {
if (typeof appConfigOrDefineAppConfig === 'function') {
return appConfigOrDefineAppConfig();
} else {
return appConfigOrDefineAppConfig;
}
}