-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.mjs
61 lines (55 loc) · 1.36 KB
/
build.mjs
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
import {NodeModulesExternal} from "@finos/perspective-esbuild-plugin/external.js";
import { build } from "@finos/perspective-esbuild-plugin/build.js";
import { BuildCss } from "@prospective.co/procss/target/cjs/procss.js";
import fs from "fs";
import path_mod from "path";
const BUILD = [
{
define: {
global: "window",
},
entryPoints: ["src/ts/index.ts"],
plugins: [NodeModulesExternal()],
format: "esm",
loader: {
".css": "text",
".html": "text",
},
outfile: "dist/esm/dock-layout.js",
},
{
define: {
global: "window",
},
entryPoints: ["src/ts/index.ts"],
plugins: [],
format: "esm",
loader: {
".css": "text",
".html": "text",
},
outfile: "dist/cdn/dock-layout.js",
},
];
function add(builder, path) {
builder.add(
path,
fs.readFileSync(path_mod.join("./src/less", path)).toString(),
);
}
async function compile_css() {
fs.mkdirSync("dist/css", { recursive: true });
fs.readdirSync("src/less").forEach(file => {
const outfile = file.replace(".less", ".css");
const builder = new BuildCss("");
add(builder, file);
fs.writeFileSync(`dist/css/${outfile}`,
builder.compile().get(outfile),
);
});
}
async function build_all() {
await compile_css();
await Promise.all(BUILD.map(build)).catch(() => process.exit(1));
}
build_all();