-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathesbuild.ts
36 lines (31 loc) · 1.03 KB
/
esbuild.ts
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
import { build, serve, BuildOptions } from 'esbuild';
const buildOptsWeb: BuildOptions = {
entryPoints: ['./src/index.ts'],
outfile: './dist/web/NodeFlow.js',
platform: 'browser',
target: ['esNext'],
format: 'esm',
bundle: true,
sourcemap: true,
minify: true,
treeShaking: true,
};
const serveOpts = { servedir: './' };
const flags = process.argv.filter(arg => /--[^=].*/.test(arg));
const enableWatch = (flags.includes('--watch'));
if (enableWatch) {
buildOptsWeb.watch = {
onRebuild: (error, result) => {
if (error) { console.error('watch web development build failed:', error); }
else { console.log('watch web development build succeeded:', result); }
}
};
serve(serveOpts, {}).then((result) => {
let host = result.host;
if (host === "0.0.0.0") {
host = "localhost"
}
console.log(`serving extension from "${serveOpts.servedir}" at "http://${host}:${result.port}"`);
});
}
build(buildOptsWeb).then(() => enableWatch ? console.log("watching web development build...") : null);