-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
55 lines (47 loc) · 1.27 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
// @flow
import babel from "rollup-plugin-babel";
import commonjs from "rollup-plugin-commonjs";
import globby from "globby";
import pascalCase from "pascal-case";
import resolve from "rollup-plugin-node-resolve";
import uglify from "rollup-plugin-uglify";
import {minify} from "uglify-es";
import pkg from "./package.json";
const plugins = {
babel: babel({
exclude: "node_modules/**",
runtimeHelpers: true
}),
commonjs: commonjs(),
resolve: resolve(),
uglify: uglify({}, minify)
};
const dirs = {
input: "src",
output: "dist",
compat: "compat"
};
const getCjsAndEsConfig = fileName => ({
input: `${dirs.input}/${fileName}`,
output: [
{file: `${dirs.output}/${fileName}`, format: "es"},
{file: `${dirs.compat}/cjs/${fileName}`, format: "cjs"}
],
plugins: [plugins.babel, plugins.uglify],
sourcemap: true
});
const sources = globby.sync("**/*js", {cwd: dirs.input});
const getUnscopedName = pkg => pkg.name.split("/")[1];
export default [
{
input: `${dirs.input}/index.js`,
output: {
file: `${dirs.compat}/umd/index.js`,
format: "umd"
},
name: pascalCase(getUnscopedName(pkg)),
plugins: [plugins.babel, plugins.resolve, plugins.commonjs, plugins.uglify],
sourcemap: true
},
...sources.map(getCjsAndEsConfig)
];