generated from ButterDebugger/deno-jsr-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbundle.ts
More file actions
30 lines (27 loc) · 815 Bytes
/
bundle.ts
File metadata and controls
30 lines (27 loc) · 815 Bytes
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
import * as esbuild from "https://deno.land/x/esbuild@v0.24.0/mod.js";
import { denoPlugins } from "jsr:@luca/esbuild-deno-loader@0.11.0";
// Create esbuild context
const ctx: esbuild.BuildContext = await esbuild.context({
plugins: [...denoPlugins()],
entryPoints: ["./src/index.ts"],
outdir: "./dist/",
bundle: true,
platform: "browser",
format: "esm",
target: "esnext",
minify: true,
sourcemap: true,
treeShaking: true,
});
if (Deno.args.includes("--watch")) {
// Enable rebuild watcher
await ctx.watch();
console.log("[Bundler] Watching source code for changes...");
} else {
// Bundle source code
await ctx.rebuild();
console.log("[Bundler] Built successfully!");
// Dispose of esbuild instance
await ctx.dispose();
Deno.exit(0);
}