-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.mjs
57 lines (46 loc) · 1.22 KB
/
esbuild.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
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
57
import * as esbuild from "esbuild";
import { dirname } from "path";
import { fileURLToPath } from "url";
const pwd = dirname(fileURLToPath(import.meta.url));
const [command, ...args] = process.argv.slice(2);
const config = {
entryPoints: [
"src/js/main.js",
"src/css/main.css",
"src/js/debug.js",
"src/index.html",
"src/debug.html",
"src/manifest.json",
],
outdir: "dist",
// Stuff you shouldn't need to edit:
target: ["chrome58", "firefox57", "safari11", "edge19"],
bundle: true,
sourcemap: true,
outExtension: { ".js": ".js" },
logLevel: "info",
loader: { ".html": "copy", ".json": "copy" },
};
switch (command) {
case "serve":
// config.outdir = "dist/";
const ctx = await esbuild.context(config);
await ctx.watch();
console.log("watching!");
let { host, port } = await ctx.serve({
// servedir: "./static",
port: 8181,
servedir: "./dist",
});
console.log(`Serving live-reload JS on ${host}:${port}`);
break;
case "build":
// config.outdir = "dist/";
config.minify = true;
await esbuild.build(config);
break;
default:
console.log('try "serve" or "build"');
process.exit(1);
}
// await esbuild.build(config);