-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.mjs
More file actions
42 lines (34 loc) · 1.02 KB
/
build.mjs
File metadata and controls
42 lines (34 loc) · 1.02 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
import { bundle } from "./tools/bundle.mjs";
import { bundle_css } from "./tools/css.mjs";
import { node_modules_external } from "./tools/externals.mjs";
import { getarg } from "./tools/getarg.mjs";
import { transform } from "lightningcss";
import fs from "fs";
import cpy from "cpy";
const BUNDLES = [
{
entryPoints: ["src/ts/index.ts"],
plugins: [node_modules_external()],
outfile: "dist/esm/index.js",
},
{
entryPoints: ["src/ts/index.ts"],
outfile: "dist/cdn/index.js",
},
];
async function build() {
// Bundle css
await bundle_css();
// Copy HTML
fs.mkdirSync("dist/html", { recursive: true });
cpy("src/html/*", "dist/html");
cpy("src/html/*", "dist/");
// Copy images
fs.mkdirSync("dist/img", { recursive: true });
cpy("src/img/*", "dist/img");
await Promise.all(BUNDLES.map(bundle)).catch(() => process.exit(1));
// Copy from dist to python
fs.mkdirSync("../python_template_rust/extension", { recursive: true });
cpy("dist/**/*", "../python_template_rust/extension");
}
build();