-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.base-config.js
46 lines (42 loc) · 1.03 KB
/
rollup.base-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
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(),
];
export const baseConfig = ({
input,
globals,
umdName,
external,
outFile,
format,
mode,
}) => ({
input,
output: {
file: path.join("./dist", outFile),
format: format,
globals,
name: format === "umd" ? umdName : undefined,
},
external,
plugins:
mode === "production"
? prodPlugins()
: format === "umd"
? devPluginsUmd()
: devPlugins(),
});