-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathesbuild.config.mjs
More file actions
52 lines (49 loc) · 1.18 KB
/
Copy pathesbuild.config.mjs
File metadata and controls
52 lines (49 loc) · 1.18 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
import * as esbuild from 'esbuild';
const isWatch = process.argv.includes('--watch');
const isProd = process.argv.includes('--prod');
const config = {
entryPoints: ['index.ts'],
bundle: true,
platform: 'node',
target: 'node22',
outfile: 'dist/index.js',
format: 'cjs',
sourcemap: false,
minify: isProd,
minifyWhitespace: true,
minifyIdentifiers: isProd, // Minify identifiers in production
minifySyntax: true,
treeShaking: true,
drop: isProd ? ['debugger'] : [],
legalComments: 'none',
// Native modules that can't be bundled
external: [
'better-sqlite3',
'talib',
'protobufjs',
'protobufjs/minimal',
'protobufjs/minimal.js',
'tsx/cjs',
'fsevents',
],
define: {
'process.env.NODE_ENV': isProd ? '"production"' : '"development"',
},
logLevel: 'warning',
mainFields: ['module', 'main'],
conditions: ['node'],
ignoreAnnotations: true,
keepNames: true,
// Mark these as pure for better tree-shaking
pure: [
'console.debug',
'console.trace',
],
};
if (isWatch) {
const ctx = await esbuild.context(config);
await ctx.watch();
console.log('Watching for changes...');
} else {
await esbuild.build(config);
}