Файли
openidea/vite.config.ts
T
Luis Felipeтаluisfelipe18 9f643af069 feat(web): openidea-server --web serves the IDE to a browser (#5134)
`openidea-server --web` serves the built frontend and the IDE backend over one HTTP + WebSocket port, directly or behind a reverse proxy that strips or keeps its path prefix.

- The rpc dispatcher gains an async `invoke` with a channel sink, so project-host commands, streaming channels and IDE events run over WebSockets as they do over `--stdio`.
- Token auth is on by default (a random token unless `--token` or `--no-auth`), binds 127.0.0.1 by default, and WebSocket upgrades must be same-origin.
- The browser serves the desktop shell commands with the trust classes the desktop declares (a test keeps them in step), and the desktop menu spec, now in `ide_host::menu`. Recent-project recording and project rename are shared ide-host ops.
- WebSocket output is queued without dropping channel data or events. A reloaded page gets back the project its window still has open; after a server restart the page reloads. One tab per window, with Take Over.
- Browser fallbacks for the title bar menu, path chooser, clipboard, dialogs, Settings and external links; a reconnecting banner and an unsaved-changes guard.
- `scripts/start-web.sh` and the guide (English and Chinese).

Co-authored-by: luisfelipe18 <[email protected]>
2026-11-26 23:00:28 +08:00

65 рядки
1.9 KiB
TypeScript

/// <reference types="vitest/config" />
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { fileURLToPath } from "node:url";
import process from "node:process";
const host = process.env.TAURI_DEV_HOST;
const webServer = process.env.OPENIDEA_WEB_SERVER;
export default defineConfig(() => ({
// Relative asset URLs keep both desktop bundles and reverse-proxied web deployments subpath-agnostic.
base: "./",
plugins: [react()],
resolve: {
alias: [
{ find: "@", replacement: fileURLToPath(new URL("./src", import.meta.url)) },
// `invoke` with remote-development routing (src/platform/tauriCore.ts).
{
find: /^@tauri-apps\/api\/core$/,
replacement: fileURLToPath(new URL("./src/platform/tauriCore.ts", import.meta.url)),
},
],
},
// Tauri: keep Rust errors visible, fixed port, don't watch the backend.
clearScreen: false,
server: {
port: 1420,
strictPort: true,
host: host || false,
hmr: host ? { protocol: "ws", host } : undefined,
...(webServer
? {
proxy: {
"/api": {
target: webServer,
ws: true,
},
},
}
: {}),
watch: {
ignored: [
"**/src-tauri/**",
"**/crates/**",
"**/target/**",
// The packages' sources and builds (not `src/features/plugins`).
`${fileURLToPath(new URL("./plugins", import.meta.url))}/**`,
],
},
},
// The app's own entry only: plugins' web pages (`plugins/**/web-src`) are
// separate projects with their own dependencies, never part of this bundle.
optimizeDeps: { entries: ["index.html"] },
build: {
target: "safari15.4",
sourcemap: true,
},
test: {
environment: "jsdom",
globals: false,
setupFiles: ["./src/test/setup.ts"],
include: ["src/**/*.test.{ts,tsx}", "perf/**/*.test.ts", "evals/**/*.test.ts", "scripts/**/*.test.ts"],
},
}));