-
Notifications
You must be signed in to change notification settings - Fork 39
/
rollup.config.js
54 lines (50 loc) · 1.16 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
42
43
44
45
46
47
48
49
50
51
52
53
54
/* eslint-disable import/no-extraneous-dependencies */
import fs from "fs";
import path from "path";
import dts from "rollup-plugin-dts";
import typescript from "@rollup/plugin-typescript";
const pluginsRoot = "src/plugins";
function listPlugins() {
const root = path.resolve(pluginsRoot);
return fs
.readdirSync(root)
.filter(
(file) =>
fs.statSync(path.resolve(root, file)).isDirectory() && fs.existsSync(path.resolve(root, file, "index.ts")),
);
}
const config = {
input: {
index: "src/index.ts",
types: "src/types.ts",
"plugins/index": `${pluginsRoot}/index.ts`,
...Object.fromEntries(
listPlugins().map((plugin) => [`plugins/${plugin}/index`, `${pluginsRoot}/${plugin}/index.ts`]),
),
},
output: [
{
dir: "dist",
format: "esm",
minifyInternalExports: false,
},
],
external: ["react", "react-dom"],
preserveEntrySignatures: "allow-extension",
treeshake: false,
};
export default [
{
...config,
plugins: [
typescript({
include: ["src/**/*"],
compilerOptions: { removeComments: true },
}),
],
},
{
...config,
plugins: [dts()],
},
];