forked from torch2424/as-bind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.lib.js
66 lines (60 loc) · 1.42 KB
/
rollup.lib.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
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import babel from "rollup-plugin-babel";
import json from "rollup-plugin-json";
import compiler from "@ampproject/rollup-plugin-closure-compiler";
import bundleSize from "rollup-plugin-bundle-size";
import pkg from "./package.json";
const sourcemapOption = process.env.PROD ? undefined : "inline";
const babelPluginConfig = {
// so Rollup can convert unsupported es6 code to es5
exclude: ["node_modules/**"],
plugins: [
["@babel/plugin-proposal-class-properties"],
["@babel/plugin-proposal-object-rest-spread"]
]
};
let plugins = [resolve(), commonjs(), json(), babel(babelPluginConfig)];
if (process.env.PROD) {
plugins = [...plugins, compiler(), bundleSize()];
}
const libBundles = [
{
input: "lib/lib.js",
output: {
file: pkg.main,
format: "cjs",
sourcemap: sourcemapOption
},
watch: {
clearScreen: false
},
plugins: plugins
},
{
input: "lib/lib.js",
output: {
file: pkg.module,
format: "esm",
sourcemap: sourcemapOption
},
watch: {
clearScreen: false
},
plugins: plugins
},
{
input: "lib/lib.js",
output: {
file: pkg.iife,
format: "iife",
sourcemap: sourcemapOption,
name: "AsBindIIFE"
},
watch: {
clearScreen: false
},
plugins: plugins
}
];
export default libBundles;