-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.js
51 lines (45 loc) · 1.28 KB
/
rollup.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
const fs = require("fs");
const path = require("path");
const rollup = require("rollup");
const nodeResolve = require("rollup-plugin-node-resolve");
const uglify = require("rollup-plugin-uglify");
const include = require("rollup-plugin-includepaths");
const rxPaths = require("rxjs/_esm5/path-mapping");
const prefix = process.argv[2];
const input = process.argv[3];
function createBundle(input) {
return rollup.rollup(
{
input: input,
plugins: [
include({ include: rxPaths() }),
nodeResolve({
jsnext: true,
module: true
}),
uglify()
],
onwarn(warning) {
if (warning.code === 'THIS_IS_UNDEFINED') return;
console.warn(warning.message);
}
}
);
}
function writeBundle(bundle, prefix) {
return bundle.write(
{
format: "iife",
file: "./docs/" + prefix + "-bundle.js",
sourcemap: true
}
);
}
(async function main(input, prefix) {
console.log(path.join(__dirname, input));
let bundle = await createBundle(input);
await writeBundle(bundle, prefix);
})(input, prefix)
.catch(err => {
console.log(err);
});