-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.main.config.ts
More file actions
67 lines (66 loc) · 1.84 KB
/
Copy pathvite.main.config.ts
File metadata and controls
67 lines (66 loc) · 1.84 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
import { defineConfig } from 'vite';
import native from 'vite-plugin-native';
// https://vitejs.dev/config
// Performance optimizations for main process (2026 best practices)
export default defineConfig({
plugins: [
native({
// Native modules that need special handling
webpack: {
// These modules contain native .node binaries
native: ['better-sqlite3', 'node-pty'],
},
}),
],
build: {
// Enable minification for smaller bundle
minify: 'esbuild',
// Target modern Node.js for smaller output
target: 'esnext',
rollupOptions: {
// Externalize native modules and packages that depend on them
// This ensures they're loaded from node_modules at runtime
external: [
'node-pty',
'@homebridge/node-pty-prebuilt-multiarch',
'better-sqlite3',
// Electron internals
'electron',
],
output: {
// Use ES modules format for better tree-shaking
format: 'es',
// Compact output
compact: true,
},
// Advanced tree shaking
treeshake: {
moduleSideEffects: false,
propertyReadSideEffects: false,
annotations: true,
},
},
// Disable source maps in production for smaller bundle
sourcemap: process.env.NODE_ENV === 'development',
// Report only essentials
reportCompressedSize: false,
},
// Prevent Vite from trying to transform native modules
optimizeDeps: {
exclude: [
'node-pty',
'@homebridge/node-pty-prebuilt-multiarch',
'better-sqlite3',
],
},
esbuild: {
// Remove dead code in production
drop: process.env.NODE_ENV === 'production' ? ['debugger'] : [],
// Modern target
target: 'esnext',
// Enable tree shaking
treeShaking: true,
// Remove legal comments
legalComments: 'none',
},
});