-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.js
More file actions
41 lines (39 loc) · 1.16 KB
/
esbuild.js
File metadata and controls
41 lines (39 loc) · 1.16 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
import esbuild from 'esbuild'
// Custom plugin to handle the # prefixed modules
const resolveVendorModulesPlugin = {
name: 'resolve-vendor-modules',
setup(build) {
build.onResolve({ filter: /^#.*$/ }, args => {
if (args.path === '#ansi-styles') {
const relativePath = "node_modules/chalk/source/vendor/ansi-styles/index.js";
const cwd = process.cwd();
return {
path: `${cwd}/${relativePath}`,
};
} else if (args.path === '#supports-color') {
const relativePath = "node_modules/chalk/source/vendor/supports-color/index.js";
const cwd = process.cwd();
return {
path: `${cwd}/${relativePath}`,
};
}
});
}
};
esbuild.build({
entryPoints: ['src/index.ts'],
outdir: 'dist',
bundle: true,
sourcemap: true,
target: 'node20',
platform: 'node',
format: 'esm',
banner: {
js: '#!/usr/bin/env node',
},
plugins: [resolveVendorModulesPlugin],
})
.then(async (result) => {
console.log('Build complete');
})
.catch(() => process.exit(1));