-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.js
43 lines (40 loc) · 1.03 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
import babel from 'rollup-plugin-babel'
import { terser } from 'rollup-plugin-terser'
import pkg from './package.json'
import replaceExt from 'replace-ext'
const config = {
input: 'src/AutolinkerWrapper.js',
external: ['autolinker', 'react', 'prop-types'],
plugins: process.env.NODE_ENV == 'production'
? [
babel({ exclude: ['node_modules/**'] }),
terser(),
]
: [
babel({ exclude: ['node_modules/**'] }),
],
}
const getName = name =>
process.env.NODE_ENV == 'production'
? replaceExt(name, '.min.js')
: name
export default [
{
...config,
output: [
{
// browser-friendly UMD build
file: getName(pkg.browser),
format: 'umd',
name: 'AutolinkerWrapper',
globals: {
autolinker: 'Autolinker',
react: 'React',
'prop-types': 'PropTypes',
},
},
{ /*CommonJS (for Node)*/ file: getName(pkg.main), format: 'cjs' },
{ /*ES module (for bundlers)*/ file: getName(pkg.module), format: 'es' },
],
},
]