-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.js
More file actions
29 lines (24 loc) · 856 Bytes
/
esbuild.js
File metadata and controls
29 lines (24 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import fs from "node:fs"
import * as esbuild from "esbuild"
const watchMode = process.argv.some(arg => arg === "--watch")
const engines = fs.readdirSync("./engines", { withFileTypes: true })
.filter(file => file.isDirectory())
.map(file => file.name)
const engineEntries = engines
.filter(engineName => fs.existsSync(`./engines/${engineName}/app/javascript/${engineName}/application.js`))
.map(engineName => ({ out: `${engineName}/application`, in: `engines/${engineName}/app/javascript/${engineName}/application.js` }))
const context = await esbuild.context({
entryPoints: [
{ out: "application", in: "app/javascript/application.js" },
...engineEntries,
],
outdir: "app/assets/builds/",
bundle: true,
sourcemap: true
})
if (watchMode) {
await context.watch()
} else {
await context.rebuild()
await context.dispose()
}