forked from danielma/unsplash-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
57 lines (53 loc) · 1.44 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
import resolve from "rollup-plugin-node-resolve"
import babel from "rollup-plugin-babel"
import commonjs from "rollup-plugin-commonjs"
import serve from "rollup-plugin-serve"
import livereload from "rollup-plugin-livereload"
import replace from "rollup-plugin-replace"
import pkg from "./package.json"
const env = process.env.NODE_ENV || "dev"
const babelPlugin = babel({ exclude: "node_modules/**" })
const replaceEnvPlugin = replace({
"process.env.NODE_ENV": JSON.stringify(env),
})
let config = null
if (env === "production") {
config = [
{
input: pkg.source,
output: {
name: "UnsplashReact",
file: pkg["umd:main"],
format: "umd",
},
plugins: [resolve({ preferBuiltins: false }), replaceEnvPlugin, babelPlugin, commonjs()],
},
{
input: "src/index.js",
output: [{ file: pkg.main, format: "cjs" }, { file: pkg.module, format: "es" }],
plugins: [babelPlugin],
},
]
} else {
config = {
input: "examples/index.js",
output: {
name: "UnsplashReactExample",
file: "examples/build.js",
format: "umd",
sourcemap: "inline",
},
plugins: [
resolve({ preferBuiltins: false }),
replaceEnvPlugin,
replace({
"process.env.UNSPLASH_ACCESS_KEY": JSON.stringify(process.env.UNSPLASH_ACCESS_KEY),
}),
babelPlugin,
commonjs(),
serve("examples"),
livereload("examples"),
],
}
}
export default config