add minimal TS bundler
This commit is contained in:
31
build.js
Normal file
31
build.js
Normal file
@@ -0,0 +1,31 @@
|
||||
// build.js
|
||||
import * as esbuild from "esbuild";
|
||||
|
||||
const isDev = process.argv.includes("--dev");
|
||||
|
||||
const config = {
|
||||
entryPoints: ["frontend/static/frontend/ts/main.ts"], // il tuo entry point
|
||||
bundle: true,
|
||||
outdir: "frontend/static/frontend/dist",
|
||||
format: "iife", // o 'iife' se serve per un tag <script> classico
|
||||
target: "es2020",
|
||||
sourcemap: isDev,
|
||||
minify: !isDev,
|
||||
logLevel: "info",
|
||||
};
|
||||
|
||||
if (isDev) {
|
||||
const ctx = await esbuild.context(config);
|
||||
await ctx.watch();
|
||||
console.log("Watching...");
|
||||
|
||||
const shutdown = async () => {
|
||||
await ctx.dispose();
|
||||
process.exit(0);
|
||||
};
|
||||
|
||||
process.on("SIGINT", shutdown);
|
||||
process.on("SIGTERM", shutdown);
|
||||
} else {
|
||||
await esbuild.build(config);
|
||||
}
|
||||
Reference in New Issue
Block a user