-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesserve.mjs
30 lines (28 loc) · 839 Bytes
/
esserve.mjs
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
import * as esbuild from 'esbuild';
const context = await esbuild.context({
entryPoints: ['index.ts', "index.html", "styles.css"],
format: "esm",
bundle: true,
sourcemap: true,
//outfile: 'dist/bundle.js',
outdir: 'dist',
loader: {
".html": "copy",
".css": "copy",
},
tsconfig: "./tsconfig.json",
plugins: [{
name: 'watch-plugin',
setup(build) {
build.onEnd(result => {
console.log("Build finished.");
if(result.errors && result.errors.length){
console.error("Build finished with errors: ", result.errors);
}
});
}
}]
});
await context.watch();
const serve = await context.serve({port: 8000});
console.log("Serving on: ", `http://${serve.host}:${serve.port}`);