aboutsummaryrefslogtreecommitdiff
path: root/static/js/index-bundle.ts
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2023-11-20 13:37:47 -0500
committertdro <tdro@noreply.example.com>2023-11-20 13:37:47 -0500
commit1a437270dfaabe0edef26e465aadb4bcc7700473 (patch)
tree99ca6f02405c3ca0df2b8755d095b172928d3e6d /static/js/index-bundle.ts
parent2f876ba73cd40fed865ab6c725939fe86d1c9cf4 (diff)
downloadcanory-1a437270dfaabe0edef26e465aadb4bcc7700473.tar.gz
canory-1a437270dfaabe0edef26e465aadb4bcc7700473.tar.bz2
canory-1a437270dfaabe0edef26e465aadb4bcc7700473.zip
static/js/bundle.ts -> static/js/index-bundle.ts
Diffstat (limited to 'static/js/index-bundle.ts')
-rw-r--r--static/js/index-bundle.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/static/js/index-bundle.ts b/static/js/index-bundle.ts
new file mode 100644
index 0000000..bb9bee7
--- /dev/null
+++ b/static/js/index-bundle.ts
@@ -0,0 +1,21 @@
+import { bundle } from "https://deno.land/x/emit@0.26.0/mod.ts";
+
+function removeSourceMap(text): string {
+ return text.replace(/^\/\/# sourceMappingURL.*$/gm, "").trim();
+}
+
+const entrypoint = await bundle(
+ "./static/js/index.ts",
+);
+
+const output = removeSourceMap(entrypoint.code);
+const file = Deno.cwd() + "/assets/js/index.js";
+const fileSize = ((await Deno.stat(file)).size / 1024).toFixed(2) + "kB";
+
+await Deno.writeTextFile(file, output, {});
+
+console.log(
+ `Bundle file:///${file}` +
+ "\n" +
+ `Emit file:///${file} (${fileSize})`,
+);