my-bitburner/build.js

37 lines
848 B
JavaScript
Raw Normal View History

2022-08-16 23:18:41 +09:00
const fs = require("fs");
const path = require("path");
const esbuild = require("esbuild");
const yargs = require("yargs");
yargs.scriptName("builder")
.usage("$0 <cmd> [args]")
.command("watch","watch and build",(yargs)=>{
},(argv)=>{
build({
watch:true,
});
})
.command("build","build",(yargs)=>{},
(argv)=>{
build();
})
.help()
.argv;
async function build(options){
options = options || {};
options.watch = options.watch || false;
let dir = fs.readdirSync("src");
dir = dir.filter(x=>x.endsWith(".ts"));
await esbuild.build({
entryPoints:dir,
bundle:true,
write: true,
treeShaking: true,
watch: options.watch,
platform: "neutral",
target:"es2020",
outdir:"./dist",
});
}