-
Notifications
You must be signed in to change notification settings - Fork 207
Expand file tree
/
Copy pathvite.config.ts
More file actions
100 lines (98 loc) · 2.72 KB
/
Copy pathvite.config.ts
File metadata and controls
100 lines (98 loc) · 2.72 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
import react from '@vitejs/plugin-react';
import fs from 'fs';
import path from 'path';
import { defineConfig } from 'vite';
import electron from 'vite-plugin-electron';
import renderer from 'vite-plugin-electron-renderer';
// https://vitejs.dev/config/
const devPort = 5175;
const katexVersion = process.env.npm_package_dependencies_katex?.replace(/^[~^]/, '') || '0.16.0';
export default defineConfig({
define: {
// KaTeX ESM bundle references this compile-time constant.
__VERSION__: JSON.stringify(katexVersion),
},
plugins: [
react(),
electron([
{
// 主进程入口文件
entry: 'src/main/main.ts',
vite: {
build: {
sourcemap: true,
outDir: 'dist-electron',
minify: false,
rollupOptions: {
external: (id) => {
const staticExternals = ['better-sqlite3', 'discord.js', 'zlib-sync', '@discordjs/opus', 'bufferutil', 'utf-8-validate', 'node-nim', 'nim-web-sdk-ng'];
if (staticExternals.includes(id)) return true;
if (id.startsWith('@larksuite/openclaw-lark-tools') || id.startsWith('@larksuite/openclaw-lark')) return true;
return false;
},
output: {
// Keep CJS format (default), but load via ESM loader.mjs
inlineDynamicImports: true,
},
},
},
},
onstart() {
// Signal that the main process bundle is ready for electron to load
fs.writeFileSync('dist-electron/.electron-ready', '');
},
},
{
// 预加载脚本入口文件
entry: 'src/main/preload.ts',
vite: {
build: {
sourcemap: true,
outDir: 'dist-electron',
minify: false,
},
},
onstart() {},
},
]),
renderer(),
],
base: process.env.NODE_ENV === 'development' ? '/' : './',
resolve: {
alias: {
'@shared': path.resolve(__dirname, './src/shared'),
'@': path.resolve(__dirname, './src/renderer'),
},
},
build: {
outDir: 'dist',
emptyOutDir: true,
sourcemap: true,
minify: false,
},
server: {
port: devPort,
strictPort: true,
host: true,
hmr: {
port: devPort,
},
watch: {
usePolling: false,
ignored: [
'**/vendor/openclaw-runtime/**',
'**/vendor/openclaw-plugins/**',
'**/vendor/hermes-runtime/**',
],
},
},
optimizeDeps: {
exclude: ['electron', '@larksuite/openclaw-lark-tools', '@larksuite/openclaw-lark'],
esbuildOptions: {
define: {
__VERSION__: JSON.stringify(katexVersion),
},
},
},
clearScreen: false,
});