-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
rollup.config.js
50 lines (47 loc) 路 1.19 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
import fs from "fs";
import path from "path";
import { preserveShebangs } from "rollup-plugin-preserve-shebangs";
import typescript from "rollup-plugin-typescript2";
const typescriptPlugin = typescript({
useTsconfigDeclarationDir: true,
tsconfigOverride: {
compilerOptions: {
module: "esnext",
declarationDir: "dist",
},
},
});
export default [
{
preserveModules: true,
input: ["src/cli.ts"],
output: [{ dir: "dist/lib", format: "cjs" }],
external: ["@svgr/core"],
plugins: [typescriptPlugin, preserveShebangs()],
},
{
preserveModules: true,
input: allFiles("shooters"),
output: [{ dir: "dist/shooters", format: "cjs" }],
plugins: [typescriptPlugin],
},
{
preserveModules: true,
input: allFiles("renderers"),
output: [{ dir: "dist/renderers", format: "esm" }],
plugins: [typescriptPlugin],
},
];
function allFiles(dirPath) {
return fs.readdirSync(dirPath).flatMap((f) => {
const filePath = path.join(dirPath, f);
const stat = fs.statSync(filePath);
if (stat.isFile()) {
return [filePath];
} else if (stat.isDirectory()) {
return [...allFiles(filePath)];
} else {
return [];
}
});
}