electron.vite.config.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { resolve } from 'path'
  2. import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
  3. import react from '@vitejs/plugin-react'
  4. import tailwindcss from '@tailwindcss/vite'
  5. import { RENDERER_CSP } from './src/shared/csp'
  6. export default defineConfig({
  7. main: {
  8. plugins: [externalizeDepsPlugin()],
  9. build: {
  10. rollupOptions: {
  11. input: {
  12. index: resolve('src/main/index.ts'),
  13. 'steam-host': resolve('src/main/steam-host.ts')
  14. }
  15. }
  16. },
  17. resolve: {
  18. alias: {
  19. '@shared': resolve('src/shared')
  20. }
  21. }
  22. },
  23. preload: {
  24. plugins: [externalizeDepsPlugin()],
  25. build: {
  26. rollupOptions: {
  27. output: {
  28. format: 'cjs',
  29. entryFileNames: '[name].cjs'
  30. }
  31. }
  32. },
  33. resolve: {
  34. alias: {
  35. '@shared': resolve('src/shared')
  36. }
  37. }
  38. },
  39. renderer: {
  40. root: 'src/renderer',
  41. resolve: {
  42. alias: {
  43. '@renderer': resolve('src/renderer/src'),
  44. '@shared': resolve('src/shared')
  45. }
  46. },
  47. plugins: [
  48. react(),
  49. tailwindcss(),
  50. {
  51. name: 'renderer-csp',
  52. apply: 'build',
  53. transformIndexHtml: () => [
  54. { tag: 'meta', attrs: { 'http-equiv': 'Content-Security-Policy', content: RENDERER_CSP }, injectTo: 'head-prepend' }
  55. ]
  56. }
  57. ]
  58. }
  59. })