-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
61 lines (53 loc) · 1.92 KB
/
Copy pathbuild.js
File metadata and controls
61 lines (53 loc) · 1.92 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const esbuild = require("esbuild");
const { readFileSync } = require("fs");
const pkg = JSON.parse(readFileSync("./package.json", "utf8"));
const banner = `/**
* NoJS Elements v${pkg.version} — Element plugins for No.JS
* Drag-and-drop, and more.
* @author ${pkg.author}
* @homepage https://elements.no-js.dev/
* @license MIT
* @repository https://github.com/no-js-dev/nojs-elements
*/`;
const shared = {
bundle: true,
banner: { js: banner },
target: ["es2020"],
};
async function build() {
// ── CDN (IIFE) ────────────────────────────────────────────────────
await esbuild.build({
...shared,
entryPoints: ["src/cdn.js"],
outfile: "dist/iife/nojs-elements.js",
format: "iife",
minify: true,
sourcemap: true,
});
// ── ESM ─────────────────────────���───────────────────��─────────────
await esbuild.build({
...shared,
entryPoints: ["src/index.js"],
outfile: "dist/esm/nojs-elements.js",
format: "esm",
minify: true,
sourcemap: true,
});
// ── CJS ─────────────────────────────────────��─────────────────────
await esbuild.build({
...shared,
entryPoints: ["src/index.js"],
outfile: "dist/cjs/nojs-elements.js",
format: "cjs",
minify: true,
sourcemap: true,
});
console.log("✓ Build complete!");
console.log(" dist/iife/nojs-elements.js — CDN / <script> tag");
console.log(" dist/esm/nojs-elements.js — ES module (import)");
console.log(" dist/cjs/nojs-elements.js — CommonJS (require)");
}
build().catch((err) => {
console.error("Build failed:", err);
process.exit(1);
});