-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
45 lines (42 loc) · 1.1 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
import progress from 'rollup-plugin-progress';
import babel from 'rollup-plugin-babel';
import {plugin as analyze} from 'rollup-plugin-analyzer';
import pkg from './package.json';
const makeExternalPredicate = () => {
const externals = [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
];
if (externals.length === 0) {
return () => false;
}
const externalPattern = new RegExp(`^(${externals.join('|')})($|/)`);
return id => externalPattern.test(id);
};
const createConfig = ({input = 'src/index.js', output} = {}) => ({
input,
output,
external: makeExternalPredicate(),
plugins: [
progress(),
babel({
exclude: 'node_modules/**',
plugins: ['external-helpers']
}),
analyze(),
].filter(Boolean)
});
export default [
createConfig({
output: [
{file: pkg.main, format: 'cjs', interop: false},
{file: pkg.module, format: 'es', interop: false},
],
}),
createConfig({
input: './test/index.test.js',
output: [
{file: './lib/test/index.test.js', format: 'cjs', interop: false},
],
}),
];