forked from ThinkInAIXYZ/deepchat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelectron.vite.config.ts
More file actions
119 lines (117 loc) · 3.29 KB
/
electron.vite.config.ts
File metadata and controls
119 lines (117 loc) · 3.29 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
import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import svgLoader from 'vite-svg-loader'
import monacoEditorPlugin from 'vite-plugin-monaco-editor-esm'
import path from 'node:path'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
main: {
plugins: [
externalizeDepsPlugin({
exclude: ['mermaid']
}),
],
resolve: {
alias: {
'@': resolve('src/main/'),
'@shared': resolve('src/shared')
}
},
build: {
rollupOptions: {
external: ['sharp', '@duckdb/node-api'],
output: {
inlineDynamicImports: true,
manualChunks: undefined, // Disable automatic chunk splitting
}
}
}
},
preload: {
plugins: [externalizeDepsPlugin()],
resolve: {
alias: {
'@shared': resolve('src/shared')
}
},
build: {
rollupOptions: {
input: {
index: resolve('src/preload/index.ts'),
floating: resolve('src/preload/floating-preload.ts')
}
}
}
},
renderer: {
define: {
'import.meta.env.VITE_ENABLE_PLAYGROUND': JSON.stringify(
process.env.VITE_ENABLE_PLAYGROUND ?? 'false'
)
},
optimizeDeps: {
include: [
'monaco-editor',
'axios'
]
},
resolve: {
alias: {
'@': resolve('src/renderer/src'),
'@shell': resolve('src/renderer/shell'),
'@shared': resolve('src/shared'),
"@shadcn": resolve('src/shadcn'),
vue: 'vue/dist/vue.esm-bundler.js'
}
},
server: {
host: '0.0.0.0' // 防止代理干扰,导致vite-electron之间ws://localhost:5713和http://localhost:5713通信失败、页面组件无法加载
},
plugins: [
tailwindcss(),
monacoEditorPlugin({
languageWorkers: ['editorWorkerService', 'typescript', 'css', 'html', 'json'],
customDistPath(_root, buildOutDir, _base) {
return path.resolve(buildOutDir, 'monacoeditorwork')
},
}),
vue({
template: {
compilerOptions: {
// 将所有带短横线的标签名都视为自定义元素
isCustomElement: (tag) => tag.startsWith('ui-resource-renderer')
}
}
}),
svgLoader(),
vueDevTools(
{
appendTo:'src/renderer/src/main.ts'
// appendTo:'src/renderer/shell/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: {
shell: resolve('src/renderer/shell/index.html'),
shellTooltipOverlay: resolve('src/renderer/shell/tooltip-overlay/index.html'),
index: resolve('src/renderer/index.html'),
floating: resolve('src/renderer/floating/index.html'),
splash: resolve('src/renderer/splash/index.html'),
settings: resolve('src/renderer/settings/index.html')
}
}
}
}
})