-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.js
57 lines (54 loc) · 1.24 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 cleanup from 'rollup-plugin-cleanup';
import pkg from './package.json'
import resolve from 'rollup-plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import { toCamelCase } from 'ntils';
import typescript from 'rollup-plugin-typescript2';
const externals = {
'react': 'React',
'react-dom': 'ReactDOM',
}
const createConf = ({
name = pkg.name,
min = false
} = {}) => {
const suffix = min ? '.min' : '';
return {
input: './src/index.ts',
output: [
{
file: `./dist/${name}-es${suffix}.js`,
format: 'es',
},
{
file: `./dist/${name}-cjs${suffix}.js`,
format: 'cjs'
},
{
file: `./dist/${name}-umd${suffix}.js`,
format: 'umd',
globals: externals,
name: toCamelCase(name, 1)
},
{
file: `./dist/${name}-iife${suffix}.js`,
format: 'iife',
globals: externals,
name: toCamelCase(name, 1)
}
],
external: Object.keys(externals),
plugins: [
resolve(),
min && terser(),
cleanup({ comments: 'none' }),
typescript({
useTsconfigDeclarationDir: true,
}),
].filter(Boolean)
};
};
export default [
createConf(),
createConf({ min: true }),
];