Binato/tooling/mangle.ts

18 lines
508 B
TypeScript
Raw Normal View History

2023-09-10 12:59:22 +01:00
import { readFileSync, writeFileSync } from "fs";
import { minify } from "terser";
const DISABLE = false;
2023-10-05 11:13:19 +01:00
writeFileSync("./build/.MANGLED", `${DISABLE}`);
2023-09-10 20:37:46 +01:00
if (DISABLE) {
2023-10-16 10:52:36 +01:00
writeFileSync("./build/Binato.js", readFileSync("./build/index.js"));
2023-09-10 20:37:46 +01:00
console.warn("[WARNING] mangle.ts is disabled!");
} else {
(async () => {
2023-10-16 10:52:36 +01:00
const mangled = await minify(readFileSync("./build/index.js").toString(), {
2023-09-10 20:37:46 +01:00
mangle: true,
toplevel: true,
});
writeFileSync("./build/Binato.min.js", `${mangled.code}`);
})();
}