diff options
author | Luiza Pagliari <lpagliari@gmail.com> | 2017-02-08 04:14:44 -0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-08 04:14:44 -0200 |
commit | 203a48b42d988e172006b1b6efad9914cad56734 (patch) | |
tree | 4dfe014b0e04b3735e7dc5000be9dea8eb458b77 /src | |
parent | 306e63c3f50915941933f2a81234fa7e2cdd48bc (diff) | |
parent | 0025613ba6d954572b88f9797b60f3b2541b8b86 (diff) | |
download | etherpad-lite-203a48b42d988e172006b1b6efad9914cad56734.zip |
Merge pull request #3136 from joassouza/fix_minify
Fix minification of JS files
Diffstat (limited to 'src')
-rw-r--r-- | src/node/utils/Minify.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/node/utils/Minify.js b/src/node/utils/Minify.js index 80652310..a56e347d 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'); @@ -400,10 +400,10 @@ 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 + 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; } function compressCSS(filename, content, callback) |