forked from color-js/color.js
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
63 lines (58 loc) · 1.15 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
58
59
60
61
62
63
import terser from "@rollup/plugin-terser";
const bundles = [
{
"file": "dist/color.global.js",
"format": "iife",
"sourcemap": true,
"name": "Color",
},
{
"file": "dist/color.js",
"format": "esm",
"sourcemap": true,
},
{
"file": "dist/color.cjs",
"format": "cjs",
"sourcemap": true,
"exports": "named",
},
];
const fnBundles = [
{
"file": "dist/color-fn.cjs",
"format": "cjs",
"sourcemap": true,
"exports": "named",
},
];
// Add minified versions of every bundle
const addMinBundle = (bundles) => {
return bundles.flatMap(bundle => {
const minBundle = Object.assign({}, bundle);
minBundle.file = minBundle.file.replace(/\.\w+$/, ".min$&");
minBundle.plugins ||= [];
minBundle.plugins.push(terser());
return [bundle, minBundle];
});
};
export default [
{
input: "src/index.js",
output: addMinBundle(bundles),
onwarn (warning, rollupWarn) {
if (warning.code !== "CIRCULAR_DEPENDENCY") {
rollupWarn(warning);
}
},
},
{
input: "src/index-fn.js",
output: addMinBundle(fnBundles),
onwarn (warning, rollupWarn) {
if (warning.code !== "CIRCULAR_DEPENDENCY") {
rollupWarn(warning);
}
},
},
];