-
Notifications
You must be signed in to change notification settings - Fork 256
/
rollup.config.js
84 lines (77 loc) · 1.87 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
73
74
75
76
77
78
79
80
81
82
83
84
import babel from "rollup-plugin-babel";
import { terser } from "rollup-plugin-terser";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import replace from "rollup-plugin-replace";
import { sizeSnapshot } from "rollup-plugin-size-snapshot";
import protoToAssign from "./rollup.proto-to-assign.plugin";
const input = "./src/index.js";
// Treat as externals all not relative and not absolute paths
// e.g. 'react' to prevent duplications in user bundle.
const isExternal = id =>
!id.startsWith("\0") && !id.startsWith(".") && !id.startsWith("/");
const external = ["react", "react-dom"];
const plugins = [
babel(),
resolve(),
commonjs(),
protoToAssign(),
sizeSnapshot()
];
const minifiedPlugins = [
...plugins,
replace({
"process.env.NODE_ENV": '"production"'
}),
babel({
babelrc: false,
plugins: [
"babel-plugin-minify-dead-code-elimination",
"babel-plugin-transform-react-remove-prop-types"
]
}),
terser({
compress: { warnings: false }
})
];
export default [
{
input,
output: {
file: "dist/react-input-mask.js",
format: "umd",
name: "ReactInputMask",
globals: { react: "React", "react-dom": "ReactDOM" }
},
external,
plugins: [
...plugins,
replace({
"process.env.NODE_ENV": '"development"'
})
]
},
{
input,
output: {
file: "dist/react-input-mask.min.js",
format: "umd",
name: "ReactInputMask",
globals: { react: "React", "react-dom": "ReactDOM" }
},
external,
plugins: minifiedPlugins
},
{
input,
output: { file: "lib/react-input-mask.development.js", format: "cjs" },
external: isExternal,
plugins
},
{
input,
output: { file: "lib/react-input-mask.production.min.js", format: "cjs" },
external: isExternal,
plugins: minifiedPlugins
}
];