forked from mbrevda/react-image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
58 lines (54 loc) · 1.09 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
import babel from 'rollup-plugin-babel'
import nodeResolve from 'rollup-plugin-node-resolve'
import minify from 'rollup-plugin-babel-minify'
import {dirname} from 'path'
import pkg from './package.json'
const input = {
index: 'jsSrc/index.js',
Img: 'jsSrc/Img.js',
useImage: 'jsSrc/useImage.js',
}
const external = (id) => !id.startsWith('.') && !id.startsWith('/')
const opts = {
input,
external,
plugins: [
babel({
runtimeHelpers: true,
}),
nodeResolve(),
],
}
export default [
{
...opts,
output: {
dir: dirname(pkg.main),
format: 'cjs',
sourcemap: true,
},
},
// umd
{
...opts,
input: 'jsSrc/index.js',
plugins: [...opts.plugins, minify({comments: false})],
output: {
file: pkg.browser,
format: 'umd',
name: 'Img',
sourcemap: true,
sourcemapPathTransform: (relativePath) =>
relativePath.replace(/^.*?\/node_modules/, '../../node_modules'),
},
},
// esm
{
...opts,
output: {
dir: dirname(pkg.module),
format: 'esm',
sourcemap: true,
},
},
]