-
Notifications
You must be signed in to change notification settings - Fork 4
/
rollup.config.js
53 lines (49 loc) · 1.26 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
const { builtinModules } = require("module")
const resolve = require("rollup-plugin-node-resolve")
const commonjs = require("rollup-plugin-commonjs")
const sourceMaps = require("rollup-plugin-sourcemaps")
const typescript = require("rollup-plugin-typescript2")
const json = require("rollup-plugin-json")
const { terser } = require("rollup-plugin-terser")
const ignore = require("rollup-plugin-ignore")
const pkg = require("./package.json")
module.exports = {
esBuild: () =>
build({
output: { file: pkg.module, format: "es", sourcemap: true },
external: []
}),
umdBuild: () =>
build({
output: {
file: pkg.browser,
name: "dfuseClient",
format: "umd",
sourcemap: true
},
resolve: {
browser: true
},
prePlugins: [ignore(builtinModules)],
postPlugins: [terser()]
})
}
function build(options) {
return {
input: `src/index.ts`,
output: options.output,
external: options.external || [],
watch: {
include: "src/**"
},
plugins: [
...(options.prePlugins || []),
json(),
typescript({ useTsconfigDeclarationDir: true }),
commonjs(),
resolve(options.resolve),
sourceMaps(),
...(options.postPlugins || [])
]
}
}