-
Notifications
You must be signed in to change notification settings - Fork 641
/
rollup.config.js
43 lines (38 loc) · 1.3 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
import * as path from "path"
import filesize from "rollup-plugin-filesize"
import resolve from "rollup-plugin-node-resolve"
import { terser } from "rollup-plugin-terser"
import replace from "rollup-plugin-replace"
const devPlugins = () => [resolve(), filesize()]
// For umd builds, set process.env.NODE_ENV to "development" since 'process' is not available in the browser
const devPluginsUmd = () => [
resolve(),
replace({ "process.env.NODE_ENV": JSON.stringify("development") }),
filesize()
]
const prodPlugins = () => [
resolve(),
replace({ "process.env.NODE_ENV": JSON.stringify("production") }),
terser(),
filesize()
]
const config = (outFile, format, mode) => ({
input: "./lib/src/index.js",
output: {
file: path.join("./dist", outFile),
format: format,
globals: {
mobx: "mobx"
},
name: format === "umd" ? "mobxStateTree" : undefined
},
external: ["mobx"],
plugins: mode === "production" ? prodPlugins() : format === "umd" ? devPluginsUmd() : devPlugins()
})
export default [
config("mobx-state-tree.js", "cjs", "development"),
config("mobx-state-tree.min.js", "cjs", "production"),
config("mobx-state-tree.umd.js", "umd", "development"),
config("mobx-state-tree.umd.min.js", "umd", "production"),
config("mobx-state-tree.module.js", "es", "development")
]