-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
202 lines (199 loc) · 5.83 KB
/
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
import vue from '@vitejs/plugin-vue';
import { existsSync, rmSync } from 'node:fs';
import { resolve } from 'node:path';
import { defineConfig } from 'vite';
import prismjs from 'vite-plugin-prismjs';
import svgLoader from 'vite-svg-loader';
import electron from './scripts/electron';
if (existsSync(resolve('main'))) rmSync(resolve('main'), { recursive: true });
export default defineConfig({
publicDir: false,
build: {
outDir: resolve('main'),
rollupOptions: {
input: resolve('src/empty.ts'),
},
},
plugins: [
electron(
{
entry: resolve('src/main/index.ts'),
vite: {
css: {
preprocessorOptions: {
scss: {
api: 'modern',
},
},
},
build: {
outDir: resolve('main'),
sourcemap: true,
rollupOptions: {
external: source => {
if (
source.startsWith('src') ||
source.startsWith('.') ||
source.startsWith('/') ||
/^[A-Za-z]:/.test(source) ||
source.includes('desktop\\\\src') ||
source.includes('desktop/src')
)
return false;
return true;
},
output: {
interop: 'compat',
},
},
minify: false,
commonjsOptions: {
requireReturnsDefault: 'preferred',
sourceMap: true,
defaultIsModuleExports: 'auto',
include: [/.*/],
},
},
},
},
{
onstart(args) {
// Notify the Renderer-Process to reload the page when the Preload-Scripts build is complete,
// instead of restarting the entire Electron App.
args.reload();
},
entry: {
chromealive: resolve('src/preload/ChromeAlivePagePreload.ts'),
desktop: resolve('src/preload/DesktopPagePreload.ts'),
menubar: resolve('src/preload/MenubarPagePreload.ts'),
},
vite: {
css: {
preprocessorOptions: {
scss: {
api: 'modern',
},
},
},
build: {
outDir: resolve('main/preload'),
},
},
},
{
onstart(args) {
// Notify the Renderer-Process to reload the page when the Preload-Scripts build is complete,
// instead of restarting the entire Electron App.
args.reload();
},
skipSettingsWrapper: true,
vite: {
css: {
preprocessorOptions: {
scss: {
api: 'modern',
},
},
},
configFile: false,
publicDir: 'public',
root: resolve('src/chrome-extension'),
base: './',
build: {
lib: {
entry: resolve('src/chrome-extension/content.ts'),
formats: ['cjs'],
fileName: () => '[name].js',
},
outDir: resolve('ui'),
emptyOutDir: false,
minify: false,
rollupOptions: {},
sourcemap: 'inline',
target: 'chrome120',
// needed for commonjs to be activated for @ulixee deps
commonjsOptions: { include: [/.+/] },
},
resolve: {
alias: {
'@': resolve('src/chrome-extension'),
},
},
},
},
{
onstart() {
// Let HMR do its thing
},
skipSettingsWrapper: true,
vite: {
css: {
preprocessorOptions: {
scss: {
api: 'modern',
},
},
},
configFile: false,
publicDir: false,
root: resolve('src/ui'),
base: './',
resolve: {
alias: {
'@': resolve('src/ui/src'),
},
},
build: {
outDir: resolve('ui'),
emptyOutDir: false,
rollupOptions: {
input: [
resolve('src/ui/desktop.html'),
resolve('src/ui/menubar.html'),
resolve('src/ui/menu-finder.html'),
resolve('src/ui/menu-primary.html'),
resolve('src/ui/menu-timetravel.html'),
resolve('src/ui/menu-url.html'),
resolve('src/ui/screen-about.html'),
resolve('src/ui/screen-input.html'),
resolve('src/ui/screen-output.html'),
resolve('src/ui/screen-reliability.html'),
resolve('src/ui/toolbar.html'),
resolve('src/ui/devtools-entrypoint.html'),
resolve('src/ui/extension/resources.html'),
resolve('src/ui/extension/hero-script.html'),
resolve('src/ui/extension/state-generator.html'),
],
external: [/@argonprotocol\/localchain.*/],
},
sourcemap: process.env.NODE_ENV === 'production',
target: 'chrome128',
modulePreload: false,
// needed for commonjs to be activated for @ulixee deps
commonjsOptions: {
defaultIsModuleExports: 'auto',
include: [/.+/],
},
},
plugins: [
vue({
template: {
compilerOptions: {
whitespace: 'preserve',
},
},
}),
svgLoader({
svgoConfig: {
multipass: true,
},
}),
prismjs({
languages: ['javascript', 'typescript', 'shell'],
}),
],
},
},
),
],
});