-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.config.js
More file actions
58 lines (55 loc) · 1.39 KB
/
esbuild.config.js
File metadata and controls
58 lines (55 loc) · 1.39 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
const esbuild = require('esbuild');
const fs = require('fs/promises');
const path = require('path');
const isWatch = process.argv.includes('--watch');
const sharedConfig = {
bundle: true,
minify: !isWatch,
sourcemap: isWatch ? 'inline' : false,
loader: {
'.woff2': 'file',
'.woff': 'file',
'.ttf': 'file',
},
};
const buildOrWatch = async (name, config) => {
const context = await esbuild.context(config);
if (isWatch) {
await context.watch();
console.log(`Watching for changes in ${name}...`);
} else {
await context.rebuild();
await context.dispose();
console.log(`Built ${name} successfully.`);
}
};
(async () => {
try {
await Promise.all([
buildOrWatch('main', {
...sharedConfig,
platform: 'node',
entryPoints: ['electron/main.ts'],
outfile: 'dist/main.js',
external: ['electron', 'better-sqlite3'],
}),
buildOrWatch('preload', {
...sharedConfig,
platform: 'node',
entryPoints: ['electron/preload.ts'],
outfile: 'dist/preload.js',
external: ['electron'],
}),
buildOrWatch('renderer', {
...sharedConfig,
platform: 'browser',
entryPoints: ['index.tsx'],
outfile: 'dist/renderer.js',
format: 'esm',
}),
]);
} catch (error) {
console.error('Build process failed:', error);
process.exit(1);
}
})();