forked from Adrinalin4ik/easy-mediasoup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
40 lines (34 loc) · 1.27 KB
/
build.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
const browserify = require('browserify');
const fs = require('fs');
const request = require('request');
const uglify = require('uglify-js');
const bundle = browserify({ standalone: 'EasyMediasoup', debug: false });
bundle.add('./es5-bundle/index');
bundle.bundle(function (err, source) {
if (err) {
console.error(err);
}
fs.writeFileSync('dist/easy-mediasoup.bundle.js', source)
minimize();
// fs.writeFileSync('dist/easy-mediasoup.bundle.min.js', uglify.minify('dist/easy-mediasoup.bundle.js'));
// uglify.minify({"dist/easy-mediasoup.bundle.js": "compiled code"}, {
// sourceMap: {
// content: "content from compiled.js.map",
// url: "minified.js.map"
// }
// })
// const adapter = fs.readFileSync('node_modules/webrtc-adapter/out/adapter.js').toString();
// fs.writeFileSync('out/simplewebrtc-with-adapter.bundle.js', `${adapter}\n${source}`);
});
function minimize(){
//get a reference to the minified version of file-1.js
var result = uglify.minify(["dist/easy-mediasoup.bundle.js"]);
fs.writeFile("dist/easy-mediasoup.bundle.min.js", result.code, function(err) {
if(err) {
console.log(err);
} else {
console.log("File was successfully saved.");
}
});
//https://skalman.github.io/UglifyJS-online/
}