-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ts
41 lines (35 loc) · 1.04 KB
/
build.ts
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
import dts from "bun-plugin-dts";
import Logger from "@rabbit-company/logger";
import fs from "fs/promises";
await fs.rm("./module", { recursive: true, force: true });
await fs.rm("./dist", { recursive: true, force: true });
Logger.info("Start bulding module...");
let moduleBuild = await Bun.build({
entrypoints: ["./src/password-entropy.ts"],
outdir: "./module",
target: "browser",
format: "esm",
plugins: [dts({ output: { noBanner: true } })],
});
if (moduleBuild.success) {
Logger.info("Bulding module complete");
} else {
Logger.error("Bulding module failed");
}
fs.cp("./src/index.html", "./dist/index.html", { recursive: true, force: true });
Logger.info("Start bundling dist...");
let distBuild = await Bun.build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
target: "browser",
format: "esm",
minify: true,
sourcemap: "none", // Bun still generates incorrect sourcemaps
plugins: [],
});
if (distBuild.success) {
Logger.info("Bundling dist complete");
} else {
Logger.error("Bundling dist failed");
Logger.error(distBuild.logs);
}