aboutsummaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2023-03-25 07:56:24 -0400
committertdro <tdro@noreply.example.com>2023-03-25 07:56:24 -0400
commit2a69db5d88ce4acda8e7892a351c6a7c790d3172 (patch)
tree558b83c536e7a517910bab3764b4608c5d9dd1a7 /static
parent14a2e29356872aeb49426ae70a0578bdfc58b29d (diff)
downloadcanory-2a69db5d88ce4acda8e7892a351c6a7c790d3172.tar.gz
canory-2a69db5d88ce4acda8e7892a351c6a7c790d3172.tar.bz2
canory-2a69db5d88ce4acda8e7892a351c6a7c790d3172.zip
static/js: Deno bundle is deprecated - replicate
Color outside the lines.. Maybe change to full async no/decoupled build and leave deno for creating eventual APIs for hugo to consume?
Diffstat (limited to 'static')
-rw-r--r--static/js/bundle.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/static/js/bundle.ts b/static/js/bundle.ts
new file mode 100644
index 0000000..ac858c4
--- /dev/null
+++ b/static/js/bundle.ts
@@ -0,0 +1,21 @@
+import { bundle } from "https://deno.land/x/emit@0.17.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})`,
+);