-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
41 lines (34 loc) · 1.01 KB
/
Copy pathbuild.js
File metadata and controls
41 lines (34 loc) · 1.01 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
const esbuild = require("esbuild");
const fs = require("fs");
const path = require("path");
const fg = require("fast-glob");
const SRC = path.resolve(__dirname, "src");
const DIST = path.resolve(__dirname, "dist");
async function build() {
fs.mkdirSync(DIST, { recursive: true });
const files = fg.sync("**/*.css", { cwd: SRC, absolute: true, ignore: ["**/imports.css"] });
// Individual files — all flat in dist/
await Promise.all(
files.map((file) =>
esbuild.build({
entryPoints: [file],
entryNames: "[name].min",
outdir: path.join(DIST, "modules"),
bundle: false,
minify: true,
loader: { ".css": "css" },
})
)
);
// Global bundle via src/imports.css
await esbuild.build({
entryPoints: [path.join(SRC, "imports.css")],
entryNames: "bundle.min",
outdir: DIST,
bundle: true,
minify: true,
loader: { ".css": "css" },
});
console.log("✅ Done");
}
build().catch((err) => { console.error(err); process.exit(1); });