-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelectron.vite.config.ts
99 lines (99 loc) · 2.61 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import generouted from '@generouted/react-router/plugin'
import ViteYaml from '@modyfi/vite-plugin-yaml'
import react from '@vitejs/plugin-react'
import { bytecodePlugin, defineConfig, externalizeDepsPlugin } from 'electron-vite'
import { merge } from 'lodash-es'
import { resolve } from 'path'
import { AliasOptions, ResolveOptions } from 'vite'
console.log('current working dir:', resolve('.'))
const resolveOptions: { resolve: ResolveOptions & { alias: AliasOptions } } = {
resolve: {
alias: {
'@renderer': resolve('src/renderer/src'),
'@main': resolve('src/main'),
'@preload': resolve('src/preload'),
'@shared': resolve('src/shared'),
'@': resolve('src'),
'~': resolve('.')
}
}
}
const externalizedEsmDeps = [
'lodash-es',
'@faker-js/faker',
'@trpc-limiter/memory',
'got',
'encryption.js',
'filenamify',
'yt-dlp-wrap',
'p-queue'
]
const isMac = !!process.env.ACTION_RUNNER?.startsWith('macos-')
const isProduction = process.env.NODE_ENV === "production";
export default defineConfig({
main: {
...resolveOptions,
plugins: [
externalizeDepsPlugin({ exclude: [...externalizedEsmDeps] }),
ViteYaml(),
...((!isMac && isProduction && [bytecodePlugin({ transformArrowFunctions: false })]) || [])
],
build: {
rollupOptions: {
output: {
manualChunks: (id: string): any => {
if (externalizedEsmDeps.find((d) => d === id)) return id
}
}
}
},
publicDir: './resources'
},
preload: {
...resolveOptions,
plugins: [
externalizeDepsPlugin({ exclude: [...externalizedEsmDeps] }),
ViteYaml(),
...((!isMac && isProduction && [bytecodePlugin({ transformArrowFunctions: false })]) || [])
]
},
renderer: {
...merge(resolveOptions, {
resolve: {
alias: {
'@': resolve('src/renderer/src')
}
}
}),
plugins: [
ViteYaml(),
react({
babel: {
plugins: [
[
'styled-jsx/babel',
{
plugins: [
[
'styled-jsx-plugin-postcss',
{
path: './postcss.config.js',
compileEnv: 'worker'
}
]
]
}
]
]
}
}),
generouted({
source: {
routes: './src/renderer/src/pages/**/{page,index}.{jsx,tsx}',
modals: './src/renderer/src/pages/**/[+]*.{jsx,tsx}'
},
output: resolve('./src/renderer/src/router.ts')
})
]
}
})