-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelectron.vite.config.js
More file actions
75 lines (74 loc) · 2.17 KB
/
electron.vite.config.js
File metadata and controls
75 lines (74 loc) · 2.17 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
import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import react from '@vitejs/plugin-react'
// vite-plugin-imp removed: no longer needed (antd fully replaced by custom UI components)
export default defineConfig({
main: {
plugins: [externalizeDepsPlugin({ exclude: ['electron-updater'] })],
build: {
outDir: 'out/main',
rollupOptions: {
input: resolve(__dirname, 'src/main/index.ts'),
output: {
entryFileNames: 'index.js',
},
},
},
},
preload: {
plugins: [externalizeDepsPlugin()],
build: {
outDir: 'out/preload',
rollupOptions: {
input: resolve(__dirname, 'src/preload/index.ts'),
output: {
entryFileNames: 'preload.js',
},
},
},
},
renderer: {
root: resolve(__dirname, 'src/renderer'),
build: {
outDir: resolve(__dirname, 'out/renderer'),
rollupOptions: {
input: resolve(__dirname, 'src/renderer/index.html'),
output: {
entryFileNames: '[name].js',
chunkFileNames: '[name].js',
assetFileNames: '[name][extname]',
},
},
},
esbuild: {
jsx: 'automatic',
include: /\.(m?ts|[jt]sx|js)$/,
exclude: [],
},
plugins: [
react(),
],
resolve: {
alias: [
{ find: '@core', replacement: resolve(__dirname, 'src/core') },
{ find: '@', replacement: resolve(__dirname, 'src/renderer') },
// Polyfill Node builtins for browser context
{ find: 'stream', replacement: 'stream-browserify' },
// 精确匹配 'punycode' (不匹配 'punycode/xxx'), 修复 ucs2 对象丢失
{ find: /^punycode$/, replacement: resolve(__dirname, 'src/renderer/utils/punycode-shim.ts') },
{ find: 'events', replacement: 'events' },
],
},
define: {
// Provide Buffer global via the buffer package
'global': 'globalThis',
'__APP_VERSION__': JSON.stringify(require('./package.json').version),
},
css: {
modules: {
localsConvention: 'camelCase',
generateScopedName: '[name]__[local]__[hash:base64:5]',
},
},
},
})