forked from xue160709/AgentOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
42 lines (40 loc) · 1.7 KB
/
Copy pathvite.config.ts
File metadata and controls
42 lines (40 loc) · 1.7 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
/**
* Vite + React + Electron(vite-plugin-electron)一体化构建配置。
* Bundles renderer (`dist/`), main (`dist-electron/main.js`), and preload entrypoints.
*/
import { defineConfig } from 'vite'
import path from 'node:path'
import react from '@vitejs/plugin-react'
import electron from 'vite-plugin-electron/simple'
// Vite 配置文件入口 / Vite config entry — https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
electron({
main: {
// 等价于 `build.lib.entry` / Shortcut for `build.lib.entry`.
entry: 'electron/main.ts',
vite: {
build: {
rollupOptions: {
external: ['@anthropic-ai/claude-agent-sdk', 'electron-updater'],
},
},
},
},
preload: {
// 等价于 `build.rollupOptions.input`;preload 可走 Web 资源用法 /
// Shortcut for `build.rollupOptions.input` (preload may bundle web assets, unlike plain lib entry).
input: path.join(__dirname, 'electron/preload.ts'),
},
// 为渲染进程补齐 Electron/Node API 垫片;若要在渲染进程直接用 Node,需在主进程开启 `nodeIntegration` /
// Polyfill Electron + Node APIs for the renderer; enabling raw Node in renderer requires `nodeIntegration` in main.
// See 👉 https://github.com/electron-vite/vite-plugin-electron-renderer
renderer: process.env.NODE_ENV === 'test'
// 测试环境下关闭 renderer 插件(避免已知兼容问题)/
// Tests: disable renderer helper — https://github.com/electron-vite/vite-plugin-electron-renderer/issues/78#issuecomment-2053600808
? undefined
: {},
}),
],
})