-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
59 lines (55 loc) · 1.17 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
const json = require("rollup-plugin-json");
const commonjs = require("rollup-plugin-commonjs");
const resolve = require("rollup-plugin-node-resolve");
const babel = require("rollup-plugin-babel");
const nodeBuiltIns = require("rollup-plugin-node-builtins");
const nodeGlobals = require("rollup-plugin-node-globals");
const uglifier = require("rollup-plugin-uglify");
const BASE_PLUGINS = [
resolve({
module: true,
main: true,
browser: true,
jsnext: true,
preferBuiltins: true
}),
commonjs({
include: "node_modules/**"
}),
json(),
babel({
babelrc: false,
presets: ["@babel/env"]
}),
nodeBuiltIns(),
nodeGlobals()
];
const BASE_CONFIG = {
input: "src/index.js",
external: ["lodash", "is-promise"],
plugins: [...BASE_PLUGINS, uglifier.uglify()]
};
const GLOBALS = {
lodash: "lodash",
"is-promise": "isPromise"
};
module.exports = [
{
...BASE_CONFIG,
output: {
file: "dist/mercury.umd.js",
format: "umd",
name: "mercury",
globals: GLOBALS
}
},
{
...BASE_CONFIG,
output: {
file: "dist/mercury.esm.js",
format: "esm",
globals: GLOBALS
},
plugins: BASE_PLUGINS
}
];