-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.js
60 lines (54 loc) · 1.35 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
const path = require('path')
const nodeResolve = require('rollup-plugin-node-resolve')
const sourceMaps = require('rollup-plugin-sourcemaps')
const useBabel = require('rollup-plugin-babel')
const typescript = require('rollup-plugin-typescript2')
const babelConfig = require('./babel.config')
const packageJson = require('./package.json')
const input = path.resolve(__dirname, packageJson.esnext)
// Plugins
const resolve = (overrides = {}) => {
return nodeResolve({
extensions: ['.ts'],
...overrides,
})
}
const babel = (overrides = {}) => {
return useBabel({
...babelConfig,
extensions: ['.ts'],
...overrides,
})
}
// Build targets
const buildCjs = {
input,
output: {
file: path.resolve(__dirname, packageJson.main),
format: 'cjs',
exports: 'named',
sourcemap: true,
},
plugins: [resolve(), typescript(), sourceMaps()],
}
const buildUmd = {
input,
output: {
file: path.resolve(__dirname, packageJson['umd:main']),
format: 'umd',
name: 'ReachSchema',
exports: 'named',
sourcemap: true,
},
plugins: [resolve(), typescript(), babel(), sourceMaps()],
}
const buildEsm = {
input,
output: {
file: path.resolve(__dirname, packageJson.module),
format: 'esm',
sourcemap: true,
},
plugins: [resolve(), typescript(), babel(), sourceMaps()],
}
module.exports = [buildCjs, buildUmd, buildEsm]