-
Notifications
You must be signed in to change notification settings - Fork 20
/
esbuild.js
42 lines (34 loc) · 822 Bytes
/
esbuild.js
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
import pkg from "./package.json" with { type: "json" };
import esbuild from "esbuild";
const date = new Date();
const banner = `/**
* ${pkg.name} v${pkg.version} build ${date.toDateString()}
* ${pkg.homepage}
* Copyright 2016 ${pkg.author.name}
* @license ${pkg.license}
*/`;
const lib = {
entryPoints: ["./src/index.ts"],
outfile: "./dist/index.js",
banner: { js: banner },
external: ["three"],
logLevel: "info",
format: "esm",
bundle: true
};
const demo = {
entryPoints: ["./demo/src/index.ts"],
outdir: "./public/demo",
minify: process.argv.includes("-m"),
logLevel: "info",
format: "iife",
target: "es6",
bundle: true
};
if(process.argv.includes("-w")) {
const ctxDemo = await esbuild.context(demo);
await ctxDemo.watch();
} else {
await esbuild.build(lib);
await esbuild.build(demo);
}