forked from Heroic-Games-Launcher/HeroicGamesLauncher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
electron.vite.config.ts
76 lines (71 loc) · 1.95 KB
/
electron.vite.config.ts
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
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import react from '@vitejs/plugin-react-swc'
import svgr from 'vite-plugin-svgr'
import path from 'path'
import type { Plugin } from 'vite'
const srcAliases = ['backend', 'frontend', 'common'].map((aliasName) => ({
find: aliasName,
replacement: path.join(__dirname, 'src', aliasName)
}))
const dependenciesToNotExternalize = [
'@xhmikosr/decompress',
'@xhmikosr/decompress-targz',
'@xhmikosr/decompress-unzip'
]
// FIXME: Potentially publish this as a dedicated plugin, if other projects
// run into the same issue
const vite_plugin_react_dev_tools: Plugin = {
name: 'react-dev-tools-replace',
transformIndexHtml: {
handler: (html) =>
html.replace(
'<!-- REACT_DEVTOOLS_SCRIPT -->',
'<script src="http://localhost:8097"></script>'
)
}
}
export default defineConfig(({ mode }) => ({
main: {
build: {
rollupOptions: {
input: 'src/backend/main.ts'
},
outDir: 'build/main',
minify: true,
sourcemap: mode === 'development' ? 'inline' : false
},
resolve: { alias: srcAliases },
plugins: [externalizeDepsPlugin({ exclude: dependenciesToNotExternalize })]
},
preload: {
build: {
rollupOptions: {
input: 'src/backend/preload.ts'
},
outDir: 'build/preload',
minify: true,
sourcemap: mode === 'development' ? 'inline' : false
},
resolve: { alias: srcAliases },
plugins: [externalizeDepsPlugin({ exclude: dependenciesToNotExternalize })]
},
renderer: {
root: '.',
build: {
rollupOptions: {
input: path.resolve('index.html')
},
target: 'esnext',
outDir: 'build',
emptyOutDir: false,
minify: true,
sourcemap: mode === 'development' ? 'inline' : false
},
resolve: { alias: srcAliases },
plugins: [
react(),
svgr(),
mode !== 'production' && vite_plugin_react_dev_tools
]
}
}))