import { resolve } from 'node:path' import { defineConfig, externalizeDepsPlugin } from 'electron-vite' import react from '@vitejs/plugin-react' const sharedDir = resolve(__dirname, 'src/shared') export default defineConfig({ main: { // Externalizes everything in `dependencies` so native modules // (better-sqlite3, and later node-pty / serialport) are `require`d from // node_modules at runtime instead of being fed through a bundler that // cannot load them. Getting this wrong produces runtime errors that look // nothing like a config problem. plugins: [externalizeDepsPlugin()], resolve: { alias: { '@shared': sharedDir }, }, }, preload: { plugins: [externalizeDepsPlugin()], resolve: { alias: { '@shared': sharedDir }, }, }, renderer: { plugins: [react()], resolve: { alias: { '@shared': sharedDir, '@renderer': resolve(__dirname, 'src/renderer/src'), }, }, }, })