Skip to content

Instantly share code, notes, and snippets.

@TomEpsilon
Created February 25, 2022 12:56
Show Gist options
  • Save TomEpsilon/69c1ed2bf432004396000a32860a1079 to your computer and use it in GitHub Desktop.
Save TomEpsilon/69c1ed2bf432004396000a32860a1079 to your computer and use it in GitHub Desktop.
// node build.js [file] -o [output]
// install terser and minimist
import{minify}from"terser";
import{readFile, writeFile}from"fs/promises";
import m from "minimist";
let p = m(process.argv.slice(2));
let a = p._[0]
if (a){
(async()=>{
const i=await readFile(a,"utf8"),
s=await minify(i);
await writeFile(p.o || a,s.code)
console.log(`✅ Built ${a} ${p.o?("at "+p.o):""}`)
})();
} else {
console.error("❎ No file specified");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment