forked from abernix/minifier-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminifier.js
32 lines (28 loc) · 778 Bytes
/
minifier.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
var uglify;
meteorJsMinify = function (source) {
var result = {};
uglify = uglify || Npm.require("uglify-es");
try {
result.code = uglify.minify(source, {
/*fromString: true,*/
compress: {
drop_debugger: false,
unused: false,
dead_code: false,
comparisons: false,
//ecma: 6,
//arrows: false
},
output: {
preamble: "/*uglify-es*/"
}
}).code;
} catch (e) {
console.error('Uglify failed, falling back to Babel', e, result.code);
// Although Babel.minify can handle a wider variety of ECMAScript
// 2015+ syntax, it is substantially slower than UglifyJS, so we use
// it only as a fallback.
result.code = Babel.minify(source).code;
}
return result;
};