-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
49 lines (45 loc) · 1.09 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
const typescript = require("rollup-plugin-typescript2");
const sourcemap = require("rollup-plugin-sourcemaps");
const cleaner = require("rollup-plugin-cleaner");
const path = require("path");
const process = require("process");
const pkg = {
path: process.cwd(),
meta: require(path.join(process.cwd(), "package.json"))
};
if (!pkg.meta.main) {
throw new Error(
'Missing "main" key in package.json - cannot compile CommonJS module.'
);
}
if (!pkg.meta.module) {
throw new Error(
'Missing "module" key in package.json - cannot compile ES6 module.'
);
}
export default {
input: pkg.path + "/src/index.ts",
output: [
{
file: pkg.path + "/" + pkg.meta.main,
format: "cjs"
},
{
file: pkg.path + "/" + pkg.meta.module,
format: "esm"
}
],
external: Object.keys(
Object.assign(pkg.meta.peerDependencies || {}, pkg.meta.dependencies || {})
),
plugins: [
cleaner({
targets: [
path.dirname(pkg.path + "/" + pkg.meta.main),
path.dirname(pkg.path + "/" + pkg.meta.module)
]
}),
typescript(),
sourcemap()
]
};