From 2a69db5d88ce4acda8e7892a351c6a7c790d3172 Mon Sep 17 00:00:00 2001 From: tdro Date: Sat, 25 Mar 2023 07:56:24 -0400 Subject: 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? --- static/js/bundle.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 static/js/bundle.ts (limited to 'static') 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})`, +); -- cgit v1.2.3