-
Notifications
You must be signed in to change notification settings - Fork 9
/
rollup.config.js
44 lines (40 loc) · 1.19 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
import { readFileSync } from 'fs';
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import nodePolyfills from 'rollup-plugin-node-polyfills';
const pkg = JSON.parse(readFileSync('./package.json'));
const startsWithRegExp = (str) => RegExp(`^${str}`);
export default [
{
input: 'src/index.ts',
output: [
{
name: 'EventBus',
file: pkg.browser,
format: 'umd',
plugins: [terser()],
sourcemap: true,
},
{
name: 'EventBus',
file: `${pkg.browser.replace(/\.min\.js$/, '.js')}`,
format: 'umd',
},
],
plugins: [commonjs(), nodePolyfills(), nodeResolve({ browser: true, preferBuiltins: false }), typescript()],
},
{
input: 'src/index.ts',
external: [
...Object.keys(pkg.dependencies || {}).map(startsWithRegExp),
...Object.keys(pkg.peerDependencies || {}).map(startsWithRegExp),
],
plugins: [commonjs(), typescript()],
output: [
{ file: pkg.main, format: 'cjs' },
{ file: pkg.module, format: 'es' },
],
},
];