-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.js
42 lines (35 loc) · 1.01 KB
/
build.js
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
30
31
32
33
34
35
36
37
38
39
40
41
42
const sourcemap = process.env.NODE_ENV === "development" ? "none" : "external";
const minify = process.env.NODE_ENV === "development" ? false : true;
console.info(`Building Frontend for ${process.env.NODE_ENV} environment`);
console.info("Copying Frontend assets...");
const list = [
[
"./node_modules/htmx.org/dist/ext/loading-states.js",
"./assets/public/js/vendor/loading-states.js",
],
];
for await (const [src, dest] of list) {
console.info(`Copying ${src} to ${dest}`);
const f = Bun.file(src);
await Bun.write(f, dest);
}
console.info("Building Frontend...");
const build = await Bun.build({
entrypoints: ["./resources/js/app.ts"],
outdir: "./assets/public/js",
minify,
sourcemap,
target: "browser",
format: "esm",
splitting: true,
manifest: true,
});
if (!build.success) {
console.error("Frontend build failed");
for (const message of build.logs) {
// Bun will pretty print the message object
console.error(message);
}
} else {
console.info("Frontend build succeeded");
}