mirror of
https://github.com/tauri-apps/tauri-inliner.git
synced 2026-02-11 05:40:57 +01:00
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.
24 lines
457 B
JavaScript
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;
|
|
} |