import { resolve } from "node:path"; import { defineConfig, externalizeDepsPlugin } from "electron-vite"; import react from "@vitejs/plugin-react"; export default defineConfig({ main: { // ws 必须外部化运行时 require:打包进 bundle 时其可选原生依赖 bufferutil 的解析产物 // 会破坏 mask fallback(客户端发帧静默丢字节 / 报 mask is not a function) plugins: [externalizeDepsPlugin({ include: ["ws"] })], resolve: { alias: [ { find: "@shared", replacement: resolve("src/shared") }, // rpa-core 包以源码形式打进主进程产物(不作为外部依赖运行时 require) { find: /^@rpa\/core$/, replacement: resolve("packages/rpa-core/src/index.ts") }, { find: /^@rpa\/core\/capabilities$/, replacement: resolve("packages/rpa-core/src/capabilities/index.ts") } ] }, build: { rollupOptions: { input: { index: resolve("src/main/index.ts"), "local-vision/ui-detect-worker": resolve("src/main/local-vision/ui-detect-worker.ts") } } } }, preload: { plugins: [externalizeDepsPlugin()], resolve: { alias: { "@shared": resolve("src/shared") } }, build: { rollupOptions: { input: { index: resolve("src/preload/index.ts") } } } }, renderer: { plugins: [react()], resolve: { alias: { "@shared": resolve("src/shared"), "@renderer": resolve("src/renderer/src") } } } });