-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelectron.vite.config.ts
More file actions
80 lines (79 loc) · 2.71 KB
/
electron.vite.config.ts
File metadata and controls
80 lines (79 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
/**
* electron-vite config — builds main, preload, and renderer in one pipeline.
* externalizeDepsPlugin() marks 'electron' and Node built-ins as external
* so they resolve to Electron's internal modules at runtime.
*/
export default defineConfig({
main: {
plugins: [externalizeDepsPlugin({ exclude: [] })],
build: {
outDir: 'out/main',
lib: {
entry: 'electron/main.ts',
formats: ['cjs'],
fileName: () => 'main.js',
},
rollupOptions: {
external: ['electron', 'electron-updater', 'electron-log'],
},
},
},
preload: {
plugins: [externalizeDepsPlugin({ exclude: [] })],
build: {
outDir: 'out/preload',
lib: {
entry: 'electron/preload.ts',
formats: ['cjs'],
fileName: () => 'preload.js',
},
rollupOptions: {
external: ['electron'],
},
},
},
renderer: {
root: '.',
/* Relative base — required under file:// in packaged Electron so
* assets resolve to the bundle instead of the filesystem root.
* Vite 8 default is `/`. See .wm-electron-audit.md V2. */
base: './',
plugins: [react(), tailwindcss()],
resolve: {
/* Force a single superdough instance — Vite may pre-bundle two copies
* (one from @strudel/web, one standalone) causing a dead audio chain */
dedupe: ['superdough', '@strudel/core', '@strudel/web', '@strudel/webaudio', '@strudel/midi', '@strudel/draw', '@strudel/codemirror'],
},
optimizeDeps: {
/* Force all strudel packages into a single pre-bundle group so
* @strudel/core is only evaluated once in dev mode */
include: [
'@strudel/core',
'@strudel/web',
'@strudel/webaudio',
'@strudel/mini',
'@strudel/tonal',
'@strudel/transpiler',
'superdough',
],
},
build: {
outDir: 'dist',
rollupOptions: {
input: 'index.html',
output: {
/* Split heavy deps into separate chunks — loaded on demand */
manualChunks(id: string) {
if (id.includes('node_modules/react-dom') || id.includes('node_modules/react/') || id.includes('node_modules/react-router') || id.includes('node_modules/zustand')) return 'vendor-react'
if (id.includes('node_modules/@codemirror')) return 'vendor-codemirror'
if (id.includes('node_modules/@xyflow')) return 'vendor-reactflow'
if (id.includes('node_modules/i18next') || id.includes('node_modules/react-i18next')) return 'vendor-i18n'
},
},
},
},
},
})