This repository has been archived on 2024-10-04. You can view files and clone it, but cannot push or open issues or pull requests.
core/build.ts

39 lines
901 B
TypeScript
Raw Normal View History

2022-10-16 01:19:45 +02:00
import {build} from "esbuild";
/**
* Build the library.
* @param devMode - Dev mode.
*/
function buildLibrary(devMode: boolean = false): void
{
// Compilation de l'application.
build({
entryPoints: ["src/index.ts"],
outfile: "lib/index.js",
bundle: true,
minify: true,
sourcemap: true,
format: "esm",
loader: {
".ts": "ts",
},
watch: devMode ? {
// Affichage suite à une recompilation.
onRebuild(error, result) {
console.log(new Date());
if (!error && result.errors.length == 0)
console.log("Successfully built.");
else
console.error("Error!");
}
} : false,
})
// Fonction lancée pour une compilation réussie.
.then(() => { console.log(new Date()); console.log("Success."); })
// Fonction lancée pour une compilation échouée.
.catch((e) => console.error(e.message));
}
// @ts-ignore
buildLibrary(process.argv?.[2] == "dev");