dependencies: upgrade uglify-js 2.6.2 -> 3.8.1 and adapt Minify

This was a major update that required code changes.
This commit is contained in:
John McLear 2020-04-03 00:05:15 +00:00
parent a286f32c2a
commit 8987c5d813
3 changed files with 96 additions and 243 deletions

View file

@ -382,6 +382,12 @@ function getFileCompressed(filename, contentType, callback) {
} else if (contentType == 'text/javascript') {
try {
content = compressJS(content);
if (content.error) {
console.error(`Error compressing JS (${filename}) using UglifyJS`, content.error);
callback('compressionError', content.error);
} else {
content = content.code.toString(); // Convert content obj code to string
}
} catch (error) {
console.error(`getFile() returned an error in getFileCompressed(${filename}, ${contentType}): ${error}`);
}
@ -406,10 +412,10 @@ function getFile(filename, callback) {
function compressJS(content)
{
var decoder = new StringDecoder('utf8');
var code = decoder.write(content); // convert from buffer to string
var codeMinified = uglifyJS.minify(code, {fromString: true}).code;
return codeMinified;
const contentAsString = content.toString();
const codeObj = uglifyJS.minify(contentAsString);
return codeObj;
}
function compressCSS(filename, content, callback)