-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
36 lines (33 loc) · 886 Bytes
/
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
const esbuild = require("esbuild");
// Check if watch mode is enabled
const watch = process.argv.includes("--watch");
// Build configuration
const buildConfig = {
entryPoints: ["src/js/ImixsFormController.js"],
bundle: true,
outfile: "app/imixs-forms.min.js",
minify: true,
sourcemap: watch ? "inline" : false, // Source Map only in Watch-Modus
format: "iife",
globalName: "ImixsForms",
// Bundle all files from src directory
loader: {
".js": "js",
},
};
// Watch mode
if (watch) {
// Start build in watch mode
esbuild.context(buildConfig).then((context) => {
context.watch();
console.log("Watching for changes...");
});
} else {
// Single build
esbuild
.build(buildConfig)
.then(() => {
console.log("Build complete");
})
.catch(() => process.exit(1));
}