-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
66 lines (62 loc) · 1.51 KB
/
rollup.config.js
File metadata and controls
66 lines (62 loc) · 1.51 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
62
63
64
65
66
import dts from "rollup-plugin-dts";
import copy from "rollup-plugin-copy";
import typescript from "@rollup/plugin-typescript";
import shebang from "rollup-plugin-add-shebang";
import { writeFile, mkdir, chmod } from "fs/promises";
function createCommonJsPackage() {
const pkg = { type: "commonjs" };
return {
name: "jsxinator",
buildEnd: async () => {
await mkdir("./dist/cjs", { recursive: true });
await writeFile("./dist/cjs/package.json", JSON.stringify(pkg, null, 2));
},
};
}
function makeExecutable() {
return {
name: "makeExecutable",
writeBundle: async () => {
await chmod("./dist/cjs/cli.js", "755");
await chmod("./dist/esm/cli.js", "755");
},
};
}
export default [
{
input: "./src/index.ts",
plugins: [
typescript(),
copy({
targets: [{ src: "./package.json", dest: "dist" }],
}),
createCommonJsPackage(),
],
output: [
{ format: "es", file: "./dist/esm/jsxinator.js" },
{ format: "cjs", file: "./dist/cjs/jsxinator.js" },
],
},
{
input: "./src/jsxinator/cli.ts",
plugins: [
typescript(),
shebang({
include: ["./dist/esm/cli.js", "./dist/cjs/cli.js"],
}),
makeExecutable(),
],
output: [
{ format: "es", file: "./dist/esm/cli.js" },
{ format: "cjs", file: "./dist/cjs/cli.js" },
],
},
{
input: "./src/index.ts",
plugins: [typescript(), dts()],
output: {
format: "es",
file: "./dist/jsxinator.d.ts",
},
},
];