forked from silverbulletmd/silverbullet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_bundle.ts
31 lines (30 loc) · 839 Bytes
/
build_bundle.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
import { denoPlugins } from "@luca/esbuild-deno-loader";
import * as esbuild from "esbuild";
await Deno.mkdir("dist", { recursive: true });
await esbuild.build({
entryPoints: {
silverbullet: "silverbullet.ts",
},
outdir: "dist",
format: "esm",
absWorkingDir: Deno.cwd(),
bundle: true,
treeShaking: true,
sourcemap: false,
logLevel: "error",
minify: true,
external: [
"https://deno.land/std@*",
],
plugins: denoPlugins({
configPath: new URL("./deno.json", import.meta.url).pathname,
}),
});
const bundleJs = await Deno.readTextFile("dist/silverbullet.js");
// Patch output JS with import.meta.main override to avoid ESBuild CLI handling
await Deno.writeTextFile(
"dist/silverbullet.js",
"import.meta.main = false;\n" + bundleJs,
);
console.log("Output in dist/silverbullet.js");
esbuild.stop();