okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge branch 'f-021-iE' into f-021-int3616148bb

main
1.2 KiB41 linesraw
1import { defineConfig } from 'vite';
2import react from '@vitejs/plugin-react';
3
4/**
5 * Strata web shell.
6 *
7 * The engine host (server/) owns hardware detection, the model registry and the
8 * local inference API. In dev we proxy /api to it so the browser talks to one
9 * origin, exactly like the packaged app does.
10 */
11export default defineConfig({
12  plugins: [
13    react(),
14    {
15      // KaTeX's stylesheet names every font three times (woff2, woff, ttf). The app's webviews all read woff2, so the other two are
16      // dropped before Vite copies the files: ~300 KB of fonts instead of ~1.1 MB, and none of it loads until an answer has math (#3268).
17      name: 'katex-woff2-only',
18      enforce: 'pre',
19      transform(code, id) {
20        if (!id.includes('katex') || !id.split('?')[0].endsWith('.css')) return null;
21        return code.replace(/,url\([^)]*\.woff\) format\("woff"\),url\([^)]*\.ttf\) format\("truetype"\)/g, '');
22      },
23    },
24  ],
25  server: {
26    port: 5199,
27    strictPort: true,
28    proxy: {
29      '/api': {
30        target: process.env.STRATA_HOST ?? 'http://127.0.0.1:8791',
31        changeOrigin: true,
32        ws: true,
33      },
34    },
35  },
36  build: {
37    target: 'es2022',
38    outDir: 'dist',
39    sourcemap: true,
40  },
41});