Files
tauri-inliner/lib/javascript.js
Sam Nguyen 8af810faa7 fix: replace with empty string if error in GET
Fixes #61

It seems to work, but I'm not sure if it's a clean way of doing it. Let
me know what you think @remy.
2015-08-28 20:20:52 -07:00

24 lines
457 B
JavaScript

module.exports = uglify;
var debug = require('debug')('inliner');
var UglifyJS = require('uglify-js');
function uglify(source) {
this.emit('progress', 'compressing javascript');
if (source.body === '') {
return '';
}
if (source.body) {
source = source.body;
}
// in case of local buffer
source = source.toString();
debug('uglifying %sbytes', source.length);
return UglifyJS.minify(source, {
fromString: true,
}).code;
}