diff options
author | joassouza <joassouzasantos@gmail.com> | 2017-02-07 13:04:22 -0200 |
---|---|---|
committer | joassouza <joassouzasantos@gmail.com> | 2017-02-07 13:04:22 -0200 |
commit | d1e6c8492d3935552100dd9023d3b16fd180fa76 (patch) | |
tree | 29021caadca829452343d4b0ac5b016457454b2f | |
parent | d65ab4d80b8b0360047488bc666468b9172611be (diff) | |
download | etherpad-lite-d1e6c8492d3935552100dd9023d3b16fd180fa76.zip |
Fix minification of code
-rw-r--r-- | src/node/utils/Minify.js | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/node/utils/Minify.js b/src/node/utils/Minify.js index 80652310..2be1fea4 100644 --- a/src/node/utils/Minify.js +++ b/src/node/utils/Minify.js @@ -23,9 +23,9 @@ var ERR = require("async-stacktrace"); var settings = require('./Settings'); var async = require('async'); var fs = require('fs'); +var StringDecoder = require('string_decoder').StringDecoder; var CleanCSS = require('clean-css'); -var jsp = require("uglify-js").parser; -var pro = require("uglify-js").uglify; +var uglifyJS = require("uglify-js"); var path = require('path'); var plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins"); var RequireKernel = require('etherpad-require-kernel'); @@ -375,7 +375,9 @@ function getFileCompressed(filename, contentType, callback) { callback(error, content); } else if (contentType == 'text/javascript') { try { - content = compressJS(content); + var decoder = new StringDecoder('utf8'); + var code = decoder.write(content); // convert from buffer to string + content = uglifyJS.minify(code, {fromString: true}).code; } catch (error) { // silence } @@ -398,14 +400,6 @@ function getFile(filename, callback) { } } -function compressJS(content) -{ - var ast = jsp.parse(content); // parse code and get the initial AST - ast = pro.ast_mangle(ast); // get a new AST with mangled names - ast = pro.ast_squeeze(ast); // get an AST with compression optimizations - return pro.gen_code(ast); // compressed code here -} - function compressCSS(filename, content, callback) { try { |