This repository has been archived by the owner on Mar 11, 2021. It is now read-only.
forked from politie/sherlock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
57 lines (52 loc) · 1.9 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
50
51
52
53
54
55
56
57
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import sourcemaps from 'rollup-plugin-sourcemaps';
const libs = ['sherlock', 'sherlock-proxy', 'sherlock-rxjs', 'sherlock-utils'];
const oldVersion = process.version.startsWith('v8');
export default [].concat.apply([], libs.map(lib => {
const pkg = require(`./dist/${lib}/package.json`);
return [
// browser-friendly UMD build
{
input: `dist/${lib}/index.js`,
output: {
file: `dist/${lib}/${pkg.browser}`,
format: 'umd',
name: pascal(lib),
sourcemap: true,
globals: {
'@politie/sherlock': 'Sherlock',
'rxjs': 'Rx',
},
},
external: [
'@politie/sherlock',
'rxjs',
],
plugins: [
sourcemaps(),
commonjs(),
resolve(),
...(oldVersion ? [] : [require('rollup-plugin-visualizer')({ filename: `dist/stats/${lib}.umd.html` })]),
],
},
// CommonJS (for Node) and ES module (for bundlers) build.
{
input: `dist/${lib}/index.js`,
external: ['@politie/sherlock', 'tslib', 'rxjs'],
output: [
{ sourcemap: true, file: `dist/${lib}/${pkg.main}`, format: 'cjs' },
{ sourcemap: true, file: `dist/${lib}/${pkg.module}`, format: 'es' },
],
plugins: [
sourcemaps(),
resolve(),
...(oldVersion ? [] : [require('rollup-plugin-visualizer')({ filename: `dist/stats/${lib}.html` })]),
],
},
];
}));
function pascal(name) {
const parts = name.split('-');
return parts.map(part => part[0].toUpperCase() + part.substr(1)).join('');
}