-
Notifications
You must be signed in to change notification settings - Fork 12
/
rollup.config.js
41 lines (37 loc) · 1.05 KB
/
rollup.config.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
37
38
39
40
41
import { copyFile, readFile, writeFile, mkdir } from "node:fs/promises";
import { minify, defineRollupSwcMinifyOption } from "rollup-plugin-swc3";
import commonjs from "@rollup/plugin-commonjs";
import nodeResolve from "@rollup/plugin-node-resolve";
// copy wasm file
await mkdir("./dist/generated/", { recursive: true });
await copyFile("./tmp/yoga.wasm", "./dist/yoga.wasm");
// copy d.ts files
let wrapAsm = await readFile("./yoga/javascript/src_js/wrapAsm.d.ts");
wrapAsm = wrapAsm
.toString()
.replace(/\.\/generated\/YGEnums/g, "./generated/YGEnums.js");
await writeFile("./dist/wrapAsm.d.ts", wrapAsm);
await copyFile(
"./yoga/javascript/src_js/generated/YGEnums.d.ts",
"./dist/generated/YGEnums.d.ts"
);
export default [
{
input: ["asm.js", "index.js", "node.js", "browser.js"],
output: {
dir: "dist",
format: "esm",
},
plugins: [
nodeResolve(),
commonjs({
esmExternals: true,
}),
minify(
defineRollupSwcMinifyOption({
compress: { passes: 2 },
})
),
],
},
];