electron.vite.config.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. console.log(mode);
  33. const config = mergeConfig(
  34. {
  35. root: '.',
  36. build: {
  37. rollupOptions: {
  38. input: {
  39. index: resolve(__dirname, 'index.html'),
  40. },
  41. },
  42. },
  43. },
  44. mode === 'production' ? productionConfig : developmentConfig
  45. );
  46. console.log(config);
  47. return config;
  48. }),
  49. });