diff --git a/esbuild.mjs b/esbuild.mjs new file mode 100644 index 0000000..7b9c1b4 --- /dev/null +++ b/esbuild.mjs @@ -0,0 +1,26 @@ +import { build, context } from 'esbuild'; + +const serve = process.argv[2] === 'serve'; + +/** @type {import('esbuild').BuildOptions} */ +const options = { + entryPoints: ['src/index.ts'], + outdir: 'public', + assetNames: 'assets/[name]-[hash]', + bundle: true, + loader: { + '.png': 'file', + '.zip': 'file', + }, + logLevel: 'info', +} + +if (!serve) { + await build(options); +} +else { + const ctx = await context(options); + + await ctx.watch(); + await ctx.serve({ servedir: 'public' }); +} \ No newline at end of file diff --git a/package.json b/package.json index 0e11852..a1b9268 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "version": "0.1.0", "description": "The sequel to IguaRPG", "scripts": { - "build": "parcel build", - "serve": "esbuild src/index.ts --bundle --loader:.png=file --loader:.zip=file --outdir=public --watch --servedir=public", + "build": "node esbuild.mjs", + "serve": "node esbuild.mjs serve", "test": "ts-node --transpileOnly test/run.ts", "test:watch": "nodemon --watch src --watch test -e ts,js,json -x npm run test" },