-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.ts
46 lines (40 loc) · 1.33 KB
/
rollup.config.ts
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
import resolve from '@rollup/plugin-node-resolve';
import typescript from "@rollup/plugin-typescript";
import commonjs from '@rollup/plugin-commonjs';
import terser from '@rollup/plugin-terser';
import { readFileSync } from 'fs';
import { RollupOptions } from 'rollup';
// eslint-disable-next-line security/detect-non-literal-fs-filename
const pkg = JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf8"));
const external: string[] = [
...Object.keys("dependencies" in pkg ? pkg.dependencies as Record<string, unknown> : {}),
...Object.keys("peerDependencies" in pkg ? pkg.peerDependencies as Record<string, unknown> : {}),
];
const plugins = [
typescript({ compilerOptions: { rootDir: "./src" } }),
commonjs(),
resolve()
];
const watchMode = process.env.ROLLUP_WATCH === "true";
const sourcemap = watchMode ? "inline" : false;
if (!watchMode) {
plugins.push(terser());
}
export default function(
//command: Record<string, unknown>
): RollupOptions[] {
return [
{
input: ['src/bootstrap.ts', 'src/cli.ts'],
plugins,
external,
output: {
format: 'esm',
dir: 'dist/',
chunkFileNames: "shared.mjs",
entryFileNames: "[name].mjs",
sourcemap
}
}
]
}