-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
66 lines (57 loc) · 1.47 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
58
59
60
61
62
63
64
65
66
import size from 'rollup-plugin-filesize'
import { terser } from 'rollup-plugin-terser'
import ts from 'rollup-plugin-ts'
const isDev = process.env.NODE_ENV !== 'production'
const external = isDev ? ['source-map-support/register'] : []
const $size = size({ showMinifiedSize: false })
const $ts = ts({
transpiler: 'babel',
babelConfig: {
plugins: isDev ? ['source-map-support'] : [],
}
})
const $terser = terser({
ecma: 2015,
compress: { passes: 2 },
mangle: true,
})
const cjs = entry => ({
external,
input: `src/${entry}.ts`,
plugins: [$ts],
output: {
file: `dist/${entry}.js`,
format: 'cjs',
sourcemap: isDev,
},
})
const release = entry => ({
input: `src/${entry}.ts`,
plugins: [$ts],
output: [
{
file: `dist/${entry}.esm.js`,
format: 'esm',
},
{
file: `dist/${entry}.umd.js`,
format: 'umd',
name: 'GetWild',
},
{
file: `dist/${entry}.umd.min.js`,
format: 'umd',
name: 'GetWild',
plugins: [$terser, $size],
},
// this is just for information: it's not packaged
{
file: `dist/data/${entry}.esm.min.js`,
format: 'esm',
plugins: [$terser, $size],
}
]
})
const config = [cjs('index'), cjs('fp')]
.concat(isDev ? [] : [release('index'), release('fp')])
export default config