-
Notifications
You must be signed in to change notification settings - Fork 153
/
rollup.config.mjs
53 lines (48 loc) · 1.05 KB
/
rollup.config.mjs
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
/* eslint-disable import/no-anonymous-default-export */
import typescript from "rollup-plugin-typescript2";
import postcss from "rollup-plugin-postcss";
import dts from "rollup-plugin-dts";
import pkg from "./package.json" assert { type: "json" };
function createExternal(dependencies) {
return Object.keys(dependencies).flatMap(
(dependency) => new RegExp(`^${dependency}(\\/.+)?`)
);
}
const input = "src/index.ts";
const external = [
...createExternal(pkg.dependencies),
...createExternal(pkg.peerDependencies),
];
export default [
{
input,
output: {
dir: "dist",
format: "cjs",
exports: "named",
sourcemap: true,
},
plugins: [typescript(), postcss()],
external,
},
{
input,
output: {
dir: "dist/es",
format: "es",
exports: "named",
sourcemap: true,
},
plugins: [typescript(), postcss()],
external,
},
{
input,
output: {
file: "dist/index.d.ts",
format: "es",
},
plugins: [dts()],
external: [...external, /\.css$/],
},
];