update build.mjs

This commit is contained in:
Nils Ramstöck
2023-10-04 15:45:21 +02:00
parent ed05b9212b
commit 02c5c003a6
3 changed files with 11 additions and 16 deletions

View File

@@ -2,24 +2,17 @@ import { context } from 'esbuild';
import { glob } from 'glob';
import {BitburnerPlugin} from 'esbuild-bitburner-plugin';
const WATCH = process.argv.includes('--watch');
const ctx = await context({
entryPoints: await glob('./servers/**/*.{js,jsx,ts,tsx}'),
bundle: true,
plugins: [BitburnerPlugin()],
write: false,
outbase: "./servers",
minify: !WATCH,
outdir: "./dist",
plugins: [BitburnerPlugin({
port: 12525
})],
bundle: true,
format: 'esm',
platform: 'node',
define: WATCH ? undefined : {
'process.env.NODE_ENV': "'production'",
},
logLevel: 'info'
platform: 'browser',
});
await ctx.rebuild();
if (WATCH) ctx.watch();
else ctx.dispose();
ctx.watch();

View File

@@ -4,8 +4,7 @@
"description": "template for external editors for the game bitburner",
"main": "index.js",
"scripts": {
"watch": "node ./build.mjs --watch",
"build": "node ./build.mjs"
"start": "node ./build.mjs"
},
"repository": {
"type": "git",

3
servers/home/example2.js Normal file
View File

@@ -0,0 +1,3 @@
export async function main(ns){
ns.tprint('hello world');
}