-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.cjs
53 lines (47 loc) · 1.25 KB
/
rollup.config.cjs
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
const packageJSON = require("./package.json");
const typescript = require("@rollup/plugin-typescript");
const resolve = require("@rollup/plugin-node-resolve");
const commonjs = require("@rollup/plugin-commonjs");
const { dts } = require("rollup-plugin-dts");
const del = require("rollup-plugin-delete");
const externalPackages = [
...Object.keys(packageJSON.dependencies || {}),
...Object.keys(packageJSON.peerDependencies || {}),
];
const regexesOfPackages = externalPackages.map(
(packageName) => new RegExp(`^${packageName}(\/.*)?`)
);
/** @type {import("rollup").RollupOptions[]} */
const config = [
{
input: "lib/index.ts",
output: [
{
file: "dist/index.js",
format: "cjs",
sourcemap: false,
},
{
file: "dist/index.esm.js",
format: "es",
sourcemap: false,
},
],
plugins: [
del({ targets: "dist", hook: "buildStart", runOnce: true }),
typescript(),
resolve(),
commonjs(),
],
external: regexesOfPackages,
},
{
input: "dist/dts/index.d.ts",
output: [{ file: "dist/index.d.ts", format: "es" }],
plugins: [
dts(),
del({ targets: "dist/dts", hook: "buildEnd", runOnce: true }),
],
},
];
module.exports = config;