Repository navigation
Expand file tree
/
Copy pathelectron.vite.config.ts
More file actions
122 lines (120 loc) · 3.73 KB
/
Copy pathelectron.vite.config.ts
File metadata and controls
122 lines (120 loc) · 3.73 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import { resolve } from 'path'
import { defineConfig } from 'electron-vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import svgLoader from 'vite-svg-loader'
import tailwindcss from '@tailwindcss/vite'
const isCustomElement = (tag: string) =>
tag === 'voice-agent-widget' || tag.startsWith('ui-resource-renderer')
const isVueDevToolsOverlayEnabled = process.env.DEEPCHAT_VUE_DEVTOOLS_OVERLAY !== '0'
export default defineConfig({
main: {
resolve: {
alias: {
'@': resolve('src/main/'),
'@shared': resolve('src/shared')
}
},
build: {
externalizeDeps: {
exclude: ['mermaid']
},
rollupOptions: {
input: {
index: resolve('src/main/index.ts'),
backgroundExecUtilityHost: resolve('src/main/backgroundExecUtilityHostEntry.ts'),
fileWatcherUtilityHost: resolve('src/main/fileWatcherUtilityHostEntry.ts'),
schedulerUtilityHost: resolve('src/main/schedulerUtilityHostEntry.ts'),
lightOcrHelper: resolve('src/main/lightOcrHelperEntry.ts')
},
external: ['sharp', '@duckdb/node-api'],
output: {
entryFileNames: '[name].js',
chunkFileNames: 'chunks/[name]-[hash].js',
manualChunks: undefined
}
}
}
},
preload: {
resolve: {
alias: {
'@shared': resolve('src/shared')
}
},
build: {
rollupOptions: {
input: {
index: resolve('src/preload/index.ts'),
splash: resolve('src/preload/splash-preload.ts'),
floating: resolve('src/preload/floating-preload.ts'),
browserOverlay: resolve('src/preload/browser-overlay-preload.ts'),
pluginSettings: resolve('src/preload/plugin-settings-preload.ts')
}
}
}
},
renderer: {
optimizeDeps: {
exclude: ['markstream-vue', 'stream-diffs'],
include: [
'@antv/infographic',
// The stream-diffs editor lazily imports Pierre's editor, whose CJS
// dependencies need prebundling even though stream-diffs is excluded.
'@pierre/diffs > lru_map',
'axios'
]
},
resolve: {
alias: {
'@': resolve('src/renderer/src'),
'@api': resolve('src/renderer/api'),
'@renderer-notifications': resolve('src/renderer/services/notifications'),
'@shared': resolve('src/shared'),
'@shadcn': resolve('src/shadcn'),
'@dc-ui': resolve('src/dc-ui'),
vue: 'vue/dist/vue.esm-bundler.js'
}
},
server: {
host: '0.0.0.0' // 防止代理干扰,导致vite-electron之间ws://localhost:5713和http://localhost:5713通信失败、页面组件无法加载
},
plugins: [
tailwindcss(),
vue({
template: {
compilerOptions: {
isCustomElement
}
}
}),
svgLoader(),
...(isVueDevToolsOverlayEnabled
? [
vueDevTools({
appendTo: 'src/renderer/src/main.ts'
})
]
: [])
],
worker: {
format: 'es'
},
build: {
minify: 'esbuild',
// Ensure CSS order in build matches import order in dev
// This prevents extracted CSS from async chunks from reordering
// and breaking cascade precedence (e.g. markdown renderer vs app styles)
cssCodeSplit: false,
rollupOptions: {
input: {
index: resolve('src/renderer/index.html'),
browserOverlay: resolve('src/renderer/browser-overlay/index.html'),
floating: resolve('src/renderer/floating/index.html'),
splash: resolve('src/renderer/splash/index.html'),
settings: resolve('src/renderer/settings/index.html')
}
}
}
}
})