-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
87 lines (78 loc) · 1.98 KB
/
rollup.config.mjs
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { importManager } from "rollup-plugin-import-manager";
import terser from "@rollup/plugin-terser";
const selectiveTerser = terser({
output: {
comments: (node, comment) => {
const text = comment.value;
const type = comment.type;
if (type === "comment2") {
return !(/BaseEx\|\w+/).test(text) && (/@license/i).test(text);
}
}
},
});
const makeBuild = (name, plugins) => {
return {
input: "src/hmac-obj.js",
output: [
{
format: "iife",
name: "HMACObj",
file: `dist/${name}.iife.js`
},
{
format: "iife",
name: "HMACObj",
file: `dist/${name}.iife.min.js`,
plugins: [selectiveTerser]
},
{
format: "es",
name: "HMACObj",
file: `dist/${name}.esm.js`
},
{
format: "es",
name: "HMACObj",
file: `dist/${name}.esm.min.js`,
plugins: [selectiveTerser]
},
],
plugins
};
};
const builds = [];
// build with base-ex included
builds.push(makeBuild(
"hmac-obj-bex",
[
importManager({
units: [
{
file: "**/hmac-obj.js",
module: "base-ex",
actions: {
select: "module",
rename: "../node_modules/base-ex/src/base-ex.js"
}
}
]
})
]
));
// build without base-ex
builds.push(makeBuild(
"hmac-obj",
[
importManager({
units: [
{
file: "**/hmac-obj.js",
module: "base-ex",
actions: "remove"
}
]
})
]
));
export default builds;