diff options
Diffstat (limited to 'static/js/index-bundle.ts')
-rw-r--r-- | static/js/index-bundle.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/static/js/index-bundle.ts b/static/js/index-bundle.ts new file mode 100644 index 0000000..61dc414 --- /dev/null +++ b/static/js/index-bundle.ts @@ -0,0 +1,18 @@ +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("INFO:", `Bundle file:///${file}`); +console.log("INFO:", `Emit file:///${file} (${fileSize})`); |