-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrollup.config.js
135 lines (114 loc) · 2.72 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
(function () {
'use strict';
// @ts-check
/**
* Rollup transform settings
* @package GZip Plugin
* @copyright Copyright (C) 2005 - 2018 Thierry Bela.
*
* dual licensed
*
* @license LGPL v3
* @license MIT License
*/
const libReady = {
input: "js/lib/lib.ready.js",
output: {
name: "LIB",
file: "js/dist/lib.ready.js",
format: "iife"
}
};
const libImages = {
input: "js/lib/index.images.js",
output: {
name: "LIB",
file: "js/dist/lib.images.js",
format: "iife"
}
};
const critical = {
input: "./worker/src/critical/critical.js",
output: {
name: 'critical',
file:"./worker/dist/critical.js",
format: "iife"
}
};
const criticalExtract = {
input: "./worker/src/critical/extract.js",
output: {
file:"./worker/dist/critical-extract.js",
format: "iife"
}
};
const serviceworker = {
input: "worker/src/index.js",
output: {
file: "worker/dist/serviceworker.js",
format: "iife"
}
};
const oneSignal = {
input: "./worker/src/onesignal/onesignal.js",
output: {
file: "./worker/dist/onesignal.js",
format: "iife"
}
};
const serviceworkerAdmin = {
input: "worker/src/administrator/index.js",
output: {
file: "worker/dist/serviceworker.administrator.js",
format: "iife"
}
};
const browserPrefetch = {
input: "worker/src/prefetch/prefetch.js",
output: {
name: "prefetch",
file: "worker/dist/browser.prefetch.js",
format: "iife"
}
};
const sync = {
input: "worker/src/sync/sw.sync.fallback.js",
output: {
file: "worker/dist/sync.fallback.js",
format: "iife"
}
};
var config = /*#__PURE__*/Object.freeze({
__proto__: null,
libReady: libReady,
libImages: libImages,
critical: critical,
criticalExtract: criticalExtract,
serviceworker: serviceworker,
oneSignal: oneSignal,
serviceworkerAdmin: serviceworkerAdmin,
browserPrefetch: browserPrefetch,
sync: sync
});
// @ts-check
const rollup = require("rollup");
for (let name in config) {
(async function (config, name) {
try {
// create a bundle
console.log('build ' + name.replace(/[A-Z]/g, function (all) { return '.' + all.toLocaleLowerCase()}) + '.js' + ' ...');
const bundle = await rollup.rollup(config);
// generate code
await bundle.generate(config.output);
// or write the bundle to disk
await bundle.write(config.output);
} catch (error) {
console.log({
name,
error
});
throw error;
}
})(config[name], name);
}
}());