-
Notifications
You must be signed in to change notification settings - Fork 42
/
rollup.config.js
51 lines (44 loc) · 1.35 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
import babel from '@rollup/plugin-babel';
import typescript from '@rollup/plugin-typescript';
import size from 'rollup-plugin-size';
import { terser } from 'rollup-plugin-terser';
const pkg = require('./package.json');
const external = Object.keys(pkg.peerDependencies).concat(/@babel\/runtime/);
const extensions = ['.js', '.tsx'];
const sharedPlugins = [
typescript({ tsconfig: './tsconfig.json' }),
babel({
babelHelpers: 'runtime',
exclude: 'node_modules/**',
extensions,
}),
size(),
];
const formats = [
{ format: 'umd', file: pkg.umd, plugins: sharedPlugins.concat([terser({ format: { comments: false } })]) },
{ format: 'cjs', file: pkg.main, plugins: sharedPlugins },
{ format: 'es', file: pkg.module, plugins: sharedPlugins },
];
const globals = {
react: 'React',
'react-router-dom': 'ReactRouterDom',
};
export default formats.map(({ plugins, file, format }) => ({
input: 'src/index.tsx',
plugins,
external,
output: {
exports: 'named',
file,
format,
name: 'react-router-breadcrumbs-hoc',
globals: format !== 'umd'
? globals
: {
...globals,
'@babel/runtime/helpers/toConsumableArray': '_toConsumableArray',
'@babel/runtime/helpers/defineProperty': '_defineProperty',
'@babel/runtime/helpers/objectWithoutProperties': '_objectWithoutProperties',
},
},
}));