import { fileURLToPath, URL } from "node:url"; import { defineConfig } from "vite"; // The sandboxed preload must be a single self-contained CJS file — Electron's // sandbox require polyfill cannot resolve relative modules ("a bundler is // required if you need to split preload code into multiple files"). tsc.preload // type-checks (noEmit); this config bundles src/preload.ts + the shared ipc.ts // channel constants into one dist/preload/preload.js with electron external. export default defineConfig({ build: { outDir: "dist/preload", emptyOutDir: true, lib: { entry: fileURLToPath(new URL("./src/preload.ts", import.meta.url)), formats: ["cjs"], fileName: () => "preload.js", }, rollupOptions: { external: ["electron"], }, }, });