weavesignal/apps/studio/vite.config.ts
The WeaveSignal contributors 466b32ab6a WeaveSignal 1.0.0 — release one
The first public release. What it does: https://weavesignal.top; what changed: CHANGELOG.md.
2026-11-04 12:15:42 +00:00

33 lines
1.5 KiB
TypeScript

// SPDX-License-Identifier: AGPL-3.0-only
// SPDX-FileCopyrightText: 2026 The WeaveSignal contributors
import { defineConfig } from 'vitest/config';
import { svelte } from '@sveltejs/vite-plugin-svelte';
// Tauri serves the built files from dist/; in development it loads the dev server.
//
// For the interface in a browser on loopback (the M2 run, tests/m2/), the dev server passes
// /api to the control plane named by WEAVESIGNAL_CONTROL_URL and adds the admin bearer from
// WEAVESIGNAL_CONTROL_TOKEN itself, so the page never holds the token.
const env = (globalThis as { process?: { env: Record<string, string | undefined> } }).process?.env ?? {};
const control = env.WEAVESIGNAL_CONTROL_URL;
const bearer = env.WEAVESIGNAL_CONTROL_TOKEN;
// The chat service (M6), its own process: /api/v1/chat goes there, socket included, with the
// same bearer (the chat takes the station's admin bearer for the studio's routes).
const chat = env.WEAVESIGNAL_CHAT_URL;
const auth = bearer ? { Authorization: `Bearer ${bearer}` } : {};
export default defineConfig({
plugins: [svelte()],
clearScreen: false,
server: {
port: Number(env.WEAVESIGNAL_STUDIO_PORT ?? 17420),
strictPort: true,
host: '127.0.0.1',
proxy: {
...(chat ? { '/api/v1/chat': { target: chat, ws: true, headers: auth } } : {}),
...(control ? { '/api': { target: control, headers: auth } } : {}),
},
},
build: { target: 'es2022', outDir: 'dist' },
test: { environment: 'node', include: ['src/**/*.test.ts'] },
});