core/ui: improve frontend build size (#5109)

* core/ui: improve frontend build size

* remove luxon

* add lodash

* remove console.log

* only generate sourcemap when watching
This commit is contained in:
Caleb Doxsey 2024-05-09 07:10:00 -06:00 committed by GitHub
parent d225288ab3
commit ab388211f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 358 additions and 297 deletions

View file

@ -1,16 +1,28 @@
import { build } from "esbuild";
/// <reference types="node" />
import { BuildOptions, build, context } from "esbuild";
build({
entryPoints: ["src/index.tsx"],
bundle: true,
outfile: "dist/index.js",
sourcemap: "inline",
watch: process.argv.includes("--watch"),
minify: !process.argv.includes("--watch"),
logLevel: "info",
loader: {
".svg": "dataurl",
".woff": "dataurl",
".woff2": "dataurl",
},
});
async function run() {
const watching = process.argv.includes("--watch");
const cfg: BuildOptions = {
entryPoints: ["src/index.tsx"],
bundle: true,
outdir: "dist",
sourcemap: watching ? "inline" : false,
minify: !watching,
logLevel: "info",
loader: {
".svg": "dataurl",
".woff": "dataurl",
".woff2": "dataurl",
},
};
if (watching) {
await (await context(cfg)).watch();
} else {
await build(cfg);
}
}
run();