-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathelectron.vite.config.mjs
More file actions
116 lines (110 loc) · 3.36 KB
/
Copy pathelectron.vite.config.mjs
File metadata and controls
116 lines (110 loc) · 3.36 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import path from 'path'
import inject from '@rollup/plugin-inject'
import react from '@vitejs/plugin-react'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import simpleGit from 'simple-git'
import svgr from 'vite-plugin-svgr'
import pkg from './package.json'
const git = simpleGit()
export default defineConfig(async ({ mode }) => {
const commitHash = (await git.revparse(['--short', 'HEAD'])).trim()
return {
main: {
build: {
sourcemap: mode === 'development',
outDir: 'build/main',
lib: { entry: 'src/main/electron.ts' }
},
resolve: {
extensions: ['.ts', '.js']
},
plugins: [
externalizeDepsPlugin({
include: ['@ledgerhq/hw-transport-node-hid', '@ledgerhq/hw-transport', 'node-hid', 'usb']
})
],
define: {
$COMMIT_HASH: JSON.stringify(commitHash || 'dev'),
$VERSION: JSON.stringify(pkg.version),
$IS_DEV: JSON.stringify(process.env.NODE_ENV !== 'production')
}
},
preload: {
build: {
lib: { entry: 'src/main/preload.ts' },
outDir: 'build/preload',
sourcemap: mode === 'development'
},
plugins: [externalizeDepsPlugin()],
resolve: {
extensions: ['.ts', '.js']
}
},
renderer: {
input: 'src/renderer/index.html',
build: {
sourcemap: mode === 'development',
outDir: 'build/renderer',
rollupOptions: {
output: {
manualChunks: {
vendor: ['react', 'react-dom', 'react-router-dom'],
crypto: ['crypto-browserify', 'stream-browserify', 'readable-stream'],
xchain: [
'@xchainjs/xchain-wallet',
'@xchainjs/xchain-doge',
'@xchainjs/xchain-litecoin',
'@xchainjs/xchain-bitcoin',
'@xchainjs/xchain-ethereum',
'@xchainjs/xchain-cosmos',
'@xchainjs/xchain-thorchain',
'@xchainjs/xchain-client',
'@xchainjs/xchain-crypto',
'@xchainjs/xchain-util'
]
}
},
plugins: [
inject({
Buffer: ['buffer', 'Buffer']
})
]
},
commonjsOptions: {
transformMixedEsModules: false
}
},
resolve: {
alias: {
process: 'process/browser',
stream: 'stream-browserify',
crypto: 'crypto-browserify',
path: path.resolve(__dirname, 'empty.js'),
url: path.resolve(__dirname, 'empty.js'),
https: path.resolve(__dirname, 'empty.js'),
http: path.resolve(__dirname, 'empty.js'),
zlib: path.resolve(__dirname, 'empty.js'),
fs: path.resolve(__dirname, 'empty.js')
},
extensions: ['.ts', '.js', '.tsx']
},
optimizeDeps: {
include: ['process', 'buffer'],
esbuildOptions: {
inject: ['./src/shims/buffer-shim.js']
}
},
plugins: [react(), svgr()],
define: {
'process.env': {}, // TODO: Fix from xchain
global: 'globalThis',
$COMMIT_HASH: JSON.stringify(commitHash || 'dev'),
$VERSION: JSON.stringify(pkg.version),
$IS_DEV: JSON.stringify(process.env.NODE_ENV !== 'production')
},
server: {
port: 3000
}
}
}
})