-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.base.js
48 lines (47 loc) · 1.02 KB
/
rollup.base.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
import { nodeResolve } from "@rollup/plugin-node-resolve";
import typescript from "rollup-plugin-typescript2";
import { terser } from "rollup-plugin-terser";
import mainPkg from "./package.json";
export const build = function (pkg) {
return {
input: pkg.source,
output: [
{
format: "esm",
file: pkg.module,
sourcemap: false,
plugins: [terser()],
exports: "named",
},
{
format: "cjs",
file: pkg.main,
sourcemap: false,
plugins: [terser()],
exports: "named",
},
{
name: pkg["umd:name"] || pkg.name,
format: "umd",
file: pkg.unpkg,
sourcemap: false,
plugins: [terser()],
exports: "named",
},
],
external: [
...require("module").builtinModules,
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
...Object.keys(mainPkg.dependencies || {}),
...Object.keys(mainPkg.peerDependencies || {}),
"react",
],
plugins: [
nodeResolve(),
typescript({
useTsconfigDeclarationDir: true,
}),
],
};
};