aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/config/backendConfigVitePlugin.ts
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-12-09 23:49:07 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-12-11 12:18:43 +0100
commit280a3fab74348697429b7bab56b3436968113d79 (patch)
treee1603153db18f7f35c1bcceb03462409f75002db /subprojects/frontend/config/backendConfigVitePlugin.ts
parentrefactor(frontend): lazy load XtextClient (diff)
downloadrefinery-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/config/backendConfigVitePlugin.ts')
-rw-r--r--subprojects/frontend/config/backendConfigVitePlugin.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/subprojects/frontend/config/backendConfigVitePlugin.ts b/subprojects/frontend/config/backendConfigVitePlugin.ts
new file mode 100644
index 00000000..7a6bc3db
--- /dev/null
+++ b/subprojects/frontend/config/backendConfigVitePlugin.ts
@@ -0,0 +1,27 @@
1import type { PluginOption } from 'vite';
2
3import type BackendConfig from '../src/xtext/BackendConfig';
4import { ENDPOINT } from '../src/xtext/BackendConfig';
5
6export default function backendConfigVitePlugin(
7 backendConfig: BackendConfig,
8): PluginOption {
9 return {
10 name: 'backend-config',
11 apply: 'serve',
12 configureServer(server) {
13 const config = JSON.stringify(backendConfig);
14 server.middlewares.use((req, res, next) => {
15 if (req.url === `/${ENDPOINT}`) {
16 res.setHeader('Content-Type', 'application/json');
17 res.end(config);
18 } else {
19 next();
20 }
21 });
22 },
23 };
24}
25
26export type { default as BackendConfig } from '../src/xtext/BackendConfig';
27export { ENDPOINT as CONFIG_ENDPOINT } from '../src/xtext/BackendConfig';