32 lines
706 B
JavaScript
32 lines
706 B
JavaScript
// 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);
|
|
}
|