-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrollup.config.js
62 lines (60 loc) · 1.42 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
import pkg from "./package.json"
import typescript from "rollup-plugin-typescript2"
import resolve from "rollup-plugin-node-resolve"
import commonjs from "rollup-plugin-commonjs"
import replace from "rollup-plugin-replace"
import { terser } from "rollup-plugin-terser"
const outputOptions = {
sourcemap: true,
freeze: false,
esModule: false,
treeshake: {
propertyReadSideEffects: false,
},
name: pkg.name,
globals: { react: "React", "react-native": "ReactNative" },
}
export default {
input: "./src/index.ts",
output: [
{
file: pkg.main,
format: "cjs",
...outputOptions,
},
{
file: pkg["umd:main"],
format: "umd",
...outputOptions,
},
{
file: pkg.module,
format: "esm",
...outputOptions,
},
],
plugins: [
typescript({
typescript: require("typescript"),
}),
resolve(),
commonjs(),
replace({
//enable find-replacing variable in JS code to use ENV varibale for conditional code
ENV: JSON.stringify(process.env.NODE_ENV || "development"), // key = var name, value = replace
}),
process.env.NODE_ENV === "production" &&
terser({
sourcemap: true,
output: { comments: false },
compress: {
keep_infinity: true,
pure_getters: true,
passes: 10,
},
ecma: 5,
toplevel: format === "cjs",
warnings: true,
}),
],
}