-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.config.js
More file actions
56 lines (47 loc) · 1.28 KB
/
esbuild.config.js
File metadata and controls
56 lines (47 loc) · 1.28 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
import esbuild from 'esbuild';
import { glob } from 'glob';
// Get all TypeScript files except tests
const srcEntries = glob.sync('src/**/*.ts', {
ignore: ['**/*.test.ts', '**/*.spec.ts', '**/__tests__/**'],
});
// Get script files
const scriptEntries = glob.sync('scripts/*.ts', {
ignore: ['**/*.test.ts', '**/*.spec.ts'],
});
const entryPoints = [...srcEntries, ...scriptEntries];
// ESM polyfill for __dirname and __filename
const esmBanner = `import { fileURLToPath as __fileURLToPath } from 'url';
import { dirname as __pathDirname } from 'path';
const __filename = __fileURLToPath(import.meta.url);
const __dirname = __pathDirname(__filename);`;
// Build configuration
const buildConfig = {
entryPoints,
outdir: 'dist',
platform: 'node',
target: 'node20',
format: 'esm',
sourcemap: false,
allowOverwrite: true,
logLevel: 'info',
preserveSymlinks: false,
splitting: false,
banner: {
js: esmBanner,
},
};
// Build function
async function build() {
try {
await esbuild.build(buildConfig);
console.log('✅ Build completed successfully');
} catch (error) {
console.error('❌ Build failed:', error);
process.exit(1);
}
}
// Run if called directly
if (import.meta.url === `file://${process.argv[1]}`) {
build();
}
export { buildConfig, build };