-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.js
107 lines (100 loc) · 2.4 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import deepcopy from "deepcopy";
import fs from "fs";
import path from "path";
import multiEntry from "rollup-plugin-multi-entry";
import sourceMaps from "rollup-plugin-sourcemaps";
import { terser } from "rollup-plugin-terser";
const resolvedBootprompt = path.resolve(__dirname, "./build/js/bootprompt");
function alsoMinified(input) {
const bundles = Array.isArray(input) ? input : [input];
const ret = [];
for (const bundle of bundles) {
const copy = deepcopy(bundle);
copy.output.file = copy.output.file.replace(/.js$/, ".min.js");
copy.plugins.push(terser());
ret.push(bundle, copy);
}
return ret;
}
function onwarn(warning, warn) {
// This warning is not useful. Yes, this is undefined. It's always been
// undefined.
if (warning.code === "THIS_IS_UNDEFINED") return;
warn(warning);
}
// eslint-disable-next-line import/no-default-export
export default alsoMinified([{
input: "build/js/bootprompt.js",
output: {
file: "build/dist/bootprompt.js",
format: "umd",
name: "bootprompt",
sourcemap: true,
globals: {
jquery: "$",
bootstrap: "",
},
},
external: ["jquery", "bootstrap"],
plugins: [
sourceMaps(),
],
onwarn,
}, {
input: "build/js/locales/*.js",
output: {
file: "build/dist/bootprompt.locales.js",
format: "umd",
sourcemap: true,
paths: {
[resolvedBootprompt]: "./bootprompt",
},
globals: {
[resolvedBootprompt]: "bootprompt",
},
},
external: ["../bootprompt"],
plugins: [
sourceMaps(),
multiEntry(),
],
onwarn,
}, {
input: ["build/js/bootprompt.js", "build/js/locales/*.js"],
output: {
file: "build/dist/bootprompt.all.js",
format: "umd",
sourcemap: true,
name: "bootprompt",
globals: {
jquery: "$",
bootstrap: "",
},
},
external: ["jquery", "bootstrap"],
plugins: [
sourceMaps(),
multiEntry(),
],
onwarn,
}, ...fs.readdirSync("build/js/locales").filter(x => /.js$/.test(x)).map(x => ({
input: `build/js/locales/${x}`,
output: {
file: `build/dist/locales/${x}`,
format: "umd",
sourcemap: true,
// Somehow the path for loading bootprompt is messed up if this paths entry
// is not used.
paths: {
[resolvedBootprompt]: "../bootprompt",
},
globals: {
[resolvedBootprompt]: "bootprompt",
},
},
external: ["../bootprompt"],
plugins: [
sourceMaps(),
],
onwarn,
}))]);