Skip to content

Commit 30f2d6b

Browse files
update build script (#30)
1 parent c9e2a9a commit 30f2d6b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

esbuildScript/build.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
const glob = require("tiny-glob");
2-
const { context } = require("esbuild");
2+
const { build, context } = require("esbuild");
33
const { envPlugin } = require("./envPlugin");
44

55
(async () => {
66
const entryPoints = await glob("./app/javascript/*.*");
7-
const ctx = await context({
7+
const options = {
88
entryPoints,
99
bundle: true,
1010
sourcemap: true,
1111
outdir: "app/assets/builds",
1212
plugins: [envPlugin],
13-
loader: { ".js": "jsx" },
14-
});
13+
loader: { ".js": "jsx" }
14+
};
1515

16-
if(process.argv.some((x) => x === "--watch")) {
16+
if (process.argv.some((x) => x === "--watch")) {
17+
const ctx = await context(options);
1718
await ctx.watch();
19+
console.log("Watching for changes...");
20+
} else {
21+
await build(options);
22+
console.log("Build complete.");
1823
}
19-
await ctx.serve();
20-
})();
24+
})();

0 commit comments

Comments
 (0)