Files
lgp-admin-plus/apps/desktop/electron.vite.config.ts
2026-08-13 19:04:28 +08:00

35 lines
1.1 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { defineConfig } from 'electron-vite';
/**
* electron-vite 构建配置
*
* 为什么不配置 renderer:
* 渲染层不由本工程构建——开发期直接加载 web-antd 的 vite dev server(http://localhost:14002),
* 生产期通过 app:// 自定义协议加载 web-antd 的生产 dist(electron-builder extraResources 拷入)。
*
* 为什么不用 externalizeDepsPlugin:
* 故意把 electron-updater / electron-log / electron-store 等运行时依赖全部打进 out/ 产物,
* 使应用的 dependencies 为空,electron-builder 无需收集 node_modules,
* 从而规避 pnpm 软链目录结构在打包期的兼容问题(asar 里只有 out/ 与 package.json)。
*/
export default defineConfig({
main: {
build: {
outDir: 'out/main',
},
},
preload: {
build: {
outDir: 'out/preload',
rollupOptions: {
output: {
// sandbox: true 的 preload 必须是 CommonJS(Electron 硬性限制),
// 这里锁定输出为 index.cjs,主进程按该文件名引用
format: 'cjs',
entryFileNames: '[name].cjs',
},
},
},
},
});