electron.vite.config.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import {
  2. defineConfig,
  3. defineViteConfig,
  4. externalizeDepsPlugin,
  5. } from 'electron-vite';
  6. import { mergeConfig } from 'vite';
  7. import { resolve } from 'path';
  8. import productionConfig from './config/vite.config.prod';
  9. import developmentConfig from './config/vite.config.dev';
  10. export default defineConfig({
  11. main: {
  12. plugins: [externalizeDepsPlugin()],
  13. build: {
  14. rollupOptions: {
  15. input: {
  16. index: resolve(__dirname, 'electron/main/index.ts'),
  17. },
  18. },
  19. },
  20. },
  21. preload: {
  22. plugins: [externalizeDepsPlugin()],
  23. build: {
  24. rollupOptions: {
  25. input: {
  26. index: resolve(__dirname, 'electron/preload/index.ts'),
  27. },
  28. },
  29. },
  30. },
  31. renderer: defineViteConfig(({ mode }) => {
  32. const config = mergeConfig(
  33. {
  34. root: '.',
  35. build: {
  36. rollupOptions: {
  37. input: {
  38. index: resolve(__dirname, 'index.html'),
  39. },
  40. },
  41. },
  42. },
  43. mode === 'production' ? productionConfig : developmentConfig
  44. );
  45. return config;
  46. }),
  47. });