Files
ChatApp/apps/desktop/electron.vite.config.ts
T
byGalax 825160ee46 feat(desktop): port v0.11.4-v0.15.2 from Tauri to Electron + Discord-parity audio (v0.16.0)
Chronological port of every Tauri release commit (v0.11.4 -> v0.15.2)
into the Electron rebuild, plus Discord-style audio handling that goes
beyond the Tauri original.

Highlights:
  - All 17 Tauri release commits ported (audio fixes, custom notification
    sound, Discord-style chat UX, profile banner, changelog page,
    Discord-parity call UX, screen-share echo + re-watch UX, audio-loop
    fix).
  - Native napi-rs audio-loopback addon with WASAPI process-loopback:
      * EXCLUDE_TARGET_PROCESS_TREE for full-screen shares -> peers
        never hear themselves echoed back through the capture.
      * INCLUDE_TARGET_PROCESS_TREE for window shares -> only the
        picked window's audio is captured, not the whole OS mixer
        (Discord parity).
      * HWND -> PID resolution via Win32 GetWindowThreadProcessId.
  - Discord-style screen-source picker (thumbnail grid, screens vs
    apps tabs, live-refreshing thumbnails).
  - Hash routing fix for packaged builds (file:// can't resolve
    BrowserRouter paths).
  - Tauri sources removed (apps/desktop/src-tauri).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 23:35:01 +02:00

91 lines
3.0 KiB
TypeScript

// electron-vite config. Three targets:
// - main: the Electron main-process entry (electron/main.ts)
// - preload: the contextBridge script (electron/preload.ts)
// - renderer: the existing React app at apps/desktop/ (unchanged root)
//
// Manual chunks + optimizeDeps config is ported from the pre-migration
// vite.config.ts so LiveKit/libsodium/supabase/react vendor bundles keep
// caching independently across app updates.
import react from '@vitejs/plugin-react';
import { defineConfig, externalizeDepsPlugin } from 'electron-vite';
import path from 'node:path';
const rendererAliases = {
'@': path.resolve(__dirname, './src'),
'@shared': path.resolve(__dirname, '../../packages/shared/src'),
'@db-types': path.resolve(__dirname, '../../packages/db-types/src'),
'@ui-web': path.resolve(__dirname, '../../packages/ui-web/src'),
};
export default defineConfig({
main: {
plugins: [externalizeDepsPlugin()],
build: {
outDir: 'out/main',
rollupOptions: {
input: path.resolve(__dirname, 'electron/main.ts'),
},
},
},
preload: {
plugins: [externalizeDepsPlugin()],
build: {
outDir: 'out/preload',
rollupOptions: {
input: path.resolve(__dirname, 'electron/preload.ts'),
},
},
},
renderer: {
root: '.',
// file:// loading from inside app.asar can't resolve root-absolute
// asset URLs (`/assets/...`) — they hit the OS root instead of the
// bundle. Relative base produces `./assets/...` which works in both
// dev (served from /) and packaged builds.
base: './',
plugins: [react()],
resolve: {
alias: rendererAliases,
},
optimizeDeps: {
// libsodium-wrappers-sumo (and the compact variant) ship broken
// "import" conditions in package exports — the ESM bundle
// references a sibling ./libsodium.mjs that isn't in the
// published artefact. Force esbuild to pick the "require"
// condition so the self-contained CJS build is used.
include: ['libsodium-wrappers-sumo'],
esbuildOptions: {
conditions: ['require', 'node', 'default'],
},
},
build: {
outDir: 'out/renderer',
rollupOptions: {
input: path.resolve(__dirname, 'index.html'),
output: {
manualChunks: (id: string): string | undefined => {
if (id.includes('node_modules/livekit-client')) return 'vendor-livekit';
if (id.includes('node_modules/libsodium-wrappers-sumo'))
return 'vendor-sodium';
if (id.includes('node_modules/@supabase')) return 'vendor-supabase';
if (
id.includes('node_modules/react-router') ||
id.includes('node_modules/react-dom') ||
id.includes('node_modules/react/')
) {
return 'vendor-react';
}
return undefined;
},
},
},
},
server: {
port: 1420,
strictPort: true,
},
clearScreen: false,
},
});