-
Notifications
You must be signed in to change notification settings - Fork 5
/
rollup.config.js
36 lines (33 loc) · 1002 Bytes
/
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
/* eslint-env node */
// import { nodeResolve } from '@rollup/plugin-node-resolve';
// import commonjs from 'rollup-plugin-commonjs';
// import resolve from 'rollup-plugin-node-resolve';
import pkg from './package.json';
import typescript from 'typescript';
import typescriptPlugin from 'rollup-plugin-typescript2';
const isProd = process.env.NODE_ENV === 'production';
const externalDepsRegexp = Object.keys(pkg.peerDependencies || {}).map(
(dep) => new RegExp(`${dep}(/.+)?`),
);
export default [
{
input: 'src/index.ts',
external: (id) => {
// We consider external any dep in peerDependecies or a sub import
// e.g. reakit, reakit/Portal
return externalDepsRegexp.reduce((acc, regexp) => {
return acc || regexp.test(id);
}, false);
},
plugins: [
typescriptPlugin({
clean: isProd,
typescript,
}),
],
output: [
{ file: pkg.module, format: 'es' },
{ file: pkg.main, format: 'cjs' },
],
},
];