mirror of
https://github.com/sigmasternchen/88x31breakout
synced 2025-03-14 23:49:00 +00:00
add watch script for esbuild
This commit is contained in:
parent
fdfe6d7bb1
commit
2f70e6f355
2 changed files with 19 additions and 3 deletions
|
@ -6,7 +6,8 @@
|
|||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "node src/build/esbuild.config.js"
|
||||
"build": "node src/build/esbuild.config.js",
|
||||
"watch": "node src/build/esbuild.config.js --watch"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -1,9 +1,24 @@
|
|||
import esbuild from "esbuild";
|
||||
import {bannerIndex} from "./banner-index.js";
|
||||
|
||||
esbuild.build({
|
||||
const config = {
|
||||
entryPoints: ['./src/index.ts'],
|
||||
bundle: true,
|
||||
outfile: './html/static/bundle.js',
|
||||
plugins: [bannerIndex],
|
||||
}).catch(() => process.exit(1));
|
||||
};
|
||||
|
||||
try {
|
||||
if (process.argv.indexOf("--watch") >= 0) {
|
||||
const ctx = await esbuild.context(config);
|
||||
|
||||
console.log("Watching...");
|
||||
await ctx.watch();
|
||||
} else {
|
||||
console.log("Building...");
|
||||
await esbuild.build(config);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue