diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-12-09 23:49:07 +0100 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-12-11 12:18:43 +0100 |
commit | 280a3fab74348697429b7bab56b3436968113d79 (patch) | |
tree | e1603153db18f7f35c1bcceb03462409f75002db /subprojects/frontend/src | |
parent | refactor(frontend): lazy load XtextClient (diff) | |
download | refinery-280a3fab74348697429b7bab56b3436968113d79.tar.gz refinery-280a3fab74348697429b7bab56b3436968113d79.tar.zst refinery-280a3fab74348697429b7bab56b3436968113d79.zip |
refactor(frontend): split vite config
Also introduces tsconfig.shared.json to keep track of source files used
both and build time and in the browser.
Diffstat (limited to 'subprojects/frontend/src')
-rw-r--r-- | subprojects/frontend/src/xtext/BackendConfig.ts | 13 | ||||
-rw-r--r-- | subprojects/frontend/src/xtext/fetchBackendConfig.ts | 12 |
2 files changed, 15 insertions, 10 deletions
diff --git a/subprojects/frontend/src/xtext/BackendConfig.ts b/subprojects/frontend/src/xtext/BackendConfig.ts new file mode 100644 index 00000000..41737c0b --- /dev/null +++ b/subprojects/frontend/src/xtext/BackendConfig.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-redeclare -- Declare types with their companion objects */ | ||
2 | |||
3 | import { z } from 'zod'; | ||
4 | |||
5 | export const ENDPOINT = 'config.json'; | ||
6 | |||
7 | const BackendConfig = z.object({ | ||
8 | webSocketURL: z.string().url(), | ||
9 | }); | ||
10 | |||
11 | type BackendConfig = z.infer<typeof BackendConfig>; | ||
12 | |||
13 | export default BackendConfig; | ||
diff --git a/subprojects/frontend/src/xtext/fetchBackendConfig.ts b/subprojects/frontend/src/xtext/fetchBackendConfig.ts index f8087a70..15e976d8 100644 --- a/subprojects/frontend/src/xtext/fetchBackendConfig.ts +++ b/subprojects/frontend/src/xtext/fetchBackendConfig.ts | |||
@@ -1,15 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-redeclare -- Declare types with their companion objects */ | 1 | import BackendConfig, { ENDPOINT } from './BackendConfig'; |
2 | |||
3 | import { z } from 'zod'; | ||
4 | |||
5 | export const BackendConfig = z.object({ | ||
6 | webSocketURL: z.string().url(), | ||
7 | }); | ||
8 | |||
9 | export type BackendConfig = z.infer<typeof BackendConfig>; | ||
10 | 2 | ||
11 | export default async function fetchBackendConfig(): Promise<BackendConfig> { | 3 | export default async function fetchBackendConfig(): Promise<BackendConfig> { |
12 | const configURL = `${import.meta.env.BASE_URL}config.json`; | 4 | const configURL = `${import.meta.env.BASE_URL}${ENDPOINT}`; |
13 | const response = await fetch(configURL); | 5 | const response = await fetch(configURL); |
14 | const rawConfig = (await response.json()) as unknown; | 6 | const rawConfig = (await response.json()) as unknown; |
15 | return BackendConfig.parse(rawConfig); | 7 | return BackendConfig.parse(rawConfig); |