Skip to content

Commit

Permalink
Write esbuild script
Browse files Browse the repository at this point in the history
  • Loading branch information
hubol committed Dec 7, 2023
1 parent a1c6df9 commit c83c9db
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
26 changes: 26 additions & 0 deletions esbuild.mjs
Original file line number Diff line number Diff line change
@@ -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' });
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down

0 comments on commit c83c9db

Please sign in to comment.