-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbundle.cjs
More file actions
29 lines (27 loc) · 710 Bytes
/
Copy pathbundle.cjs
File metadata and controls
29 lines (27 loc) · 710 Bytes
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
const header = `#!/usr/bin/env node
const require = (await import("module")).createRequire(import.meta.url);`;
const watch = process.argv.includes("--watch") && {
onRebuild(error, result) {
if (error) console.error('watch build failed:', error)
else console.log('Rebuild succeeded.')
}
}
require('esbuild').build({
entryPoints: ['src/index.ts'],
bundle: true,
banner: {
js: header,
},
format: "esm",
minifyWhitespace: true,
platform: 'node',
target: ['node14.17'],
external: ["worker-farm", "node:*"],
outfile: 'dist/index.mjs',
sourcemap: true,
watch
}).then(() => {
console.log("Build complete.");
if (!!watch)
console.log("Watching for file changes.");
});