-
Notifications
You must be signed in to change notification settings - Fork 10
/
esbuild.js
45 lines (41 loc) · 1.03 KB
/
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
43
44
45
import { createRequire } from "module";
import esbuild from "esbuild";
const require = createRequire(import.meta.url);
const pkg = require("./package");
const date = (new Date()).toDateString();
const external = Object.keys(pkg.peerDependencies || {});
const minify = process.argv.includes("-m");
const watch = process.argv.includes("-w");
const banner = `/**
* ${pkg.name} v${pkg.version} build ${date}
* ${pkg.homepage}
* Copyright ${date.slice(-4)} ${pkg.author.name}
* @license ${pkg.license}
*/`;
await esbuild.build({
entryPoints: [
"src/worker/worker.js"
],
outExtension: { ".js": ".txt" },
outdir: "tmp",
format: "iife",
bundle: true,
minify,
watch
}).catch(() => process.exit(1));
await esbuild.build({
entryPoints: ["demo/src/index.js"],
outdir: "public/demo",
format: "iife",
bundle: true,
minify,
watch
}).catch(() => process.exit(1));
await esbuild.build({
entryPoints: ["src/index.js"],
outfile: `dist/${pkg.name}.js`,
banner: { js: banner },
format: "esm",
bundle: true,
external
}).catch(() => process.exit(1));