-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.js
52 lines (46 loc) · 1014 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
43
44
45
46
47
48
49
50
51
52
const fs = require("fs");
const path = require("path");
const { buildSync: esbuild } = require("esbuild");
/** @type {import("esbuild").BuildOptions} */
const options = {
entryPoints: fs
.readdirSync(path.join(__dirname, "src"))
.filter(f => f.endsWith(".ts"))
.map(f => "src/" + f),
target: "es2021",
bundle: false,
loader: { ".ts": "ts" },
sourcemap: "linked",
charset: "utf8"
};
esbuild({
...options,
outdir: "cjs",
format: "cjs"
});
esbuild({
...options,
outdir: "esm",
format: "esm"
});
/** @type {import("esbuild").BuildOptions} */
const bundleOptions = {
entryPoints: ["src/index.ts"],
target: "es2021",
bundle: true,
loader: { ".ts": "ts" },
format: "iife",
globalName: "crypchar",
sourcemap: false,
charset: "utf8"
};
esbuild({
...bundleOptions,
minify: false,
outfile: "dist/crypchar.js"
});
esbuild({
...bundleOptions,
minify: true,
outfile: "dist/crypchar.min.js"
});