-
Notifications
You must be signed in to change notification settings - Fork 60
/
rollup.config.js
72 lines (65 loc) · 1.7 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
61
62
63
64
65
66
67
68
69
70
71
72
/* eslint-disable */
import babel from "rollup-plugin-babel";
import commonjs from "rollup-plugin-commonjs";
import inject from "rollup-plugin-inject";
import json from "rollup-plugin-json";
import nodeResolve from "rollup-plugin-node-resolve";
import replace from "rollup-plugin-replace";
import { uglify } from "rollup-plugin-uglify";
import filesize from "rollup-plugin-filesize";
import copy from 'rollup-plugin-copy';
const processShim = "\0process-shim";
const prod = process.env.PRODUCTION;
const env = prod ? "production" : "development";
console.log(`Creating ${env} bundle...`);
const targets = prod
? [{ dest: "dist/hedron.min.js", format: "umd" }]
: [
{ dest: "dist/hedron.js", format: "umd" },
{ dest: "dist/hedron.es.js", format: "es" },
];
const plugins = [
{
resolveId(importee) {
if (importee === processShim) return importee;
return null;
},
load(id) {
if (id === processShim) return "export default { argv: [], env: {} }";
return null;
},
},
babel({
exclude: "node_modules/**",
babelrc: false,
presets: ["es2015-rollup", "react", "stage-2"],
plugins: ["array-includes", "external-helpers"],
}),
filesize(),
commonjs(),
inject({
process: processShim,
}),
json(),
nodeResolve(),
replace({
"process.env.NODE_ENV": JSON.stringify(prod ? "production" : "development"),
}),
copy({
"src/index.d.ts": "dist/index.d.ts",
verbose: true
})
];
if (prod) plugins.push(uglify());
export default {
entry: "src/index.js",
exports: "named",
external: ["react", "styled-components"],
globals: {
react: "React",
"styled-components": "styled",
},
moduleName: "hedron",
plugins,
targets,
};