import { dir } from "dir"; import { Plugin, context } from "esbuild"; import { $ } from "execa"; import { removeAsync, writeAsync } from "fs-jetpack"; await removeAsync(dir.path("app/srv/site")); const onEndPlugin: Plugin = { name: "on-end", setup(build) { build.onEnd(async (result) => { console.log("Compressing deploy"); await removeAsync(dir.path("app/srv/site.zip")); await $({ cwd: dir.path("app/srv") })`zip -r site.zip site`; process.exit(0); }); }, }; console.log("Building deploy"); const ctx = await context({ bundle: true, absWorkingDir: dir.path(""), entryPoints: [dir.path("app/web/src/render/site/site.tsx")], outdir: dir.path("app/srv/site"), splitting: true, format: "esm", jsx: "transform", minify: true, sourcemap: true, logLevel: "error", plugins: [onEndPlugin], define: { "process.env.NODE_ENV": `"production"`, }, }); await ctx.rebuild(); await writeAsync( dir.path("app/srv/site/index.html"), `