Binato/tooling/mangle.ts
2023-10-05 11:13:19 +01:00

18 lines
No EOL
513 B
TypeScript

import { readFileSync, writeFileSync } from "fs";
import { minify } from "terser";
const DISABLE = true;
writeFileSync("./build/.MANGLED", `${DISABLE}`);
if (DISABLE) {
writeFileSync("./build/Binato.js", readFileSync("./build/combined.js"));
console.warn("[WARNING] mangle.ts is disabled!");
} else {
(async () => {
const mangled = await minify(readFileSync("./build/combined.js").toString(), {
mangle: true,
toplevel: true,
});
writeFileSync("./build/Binato.min.js", `${mangled.code}`);
})();
}