diff --git a/lib/jsminify.js b/lib/jsminify.js index 5560b0e..009e4c3 100644 --- a/lib/jsminify.js +++ b/lib/jsminify.js @@ -29,15 +29,9 @@ exports.jsminify = function (code, config, callback) { } config = config || exports.config; var comments = [], - token = '"yUglify: preserved comment block"', + token = 'function fn(){"yUglify: preserved comment block";}', reMultiComments = /\/\*![\s\S]*?\*\//g, - /* - In some cases Uglify adds a comma, in others it doesn't - So we have to process the tokens twice, first with the comma - then without it to catch both cases and to be clear about it. - */ - reTokens1 = new RegExp(token + ',', 'g'), - reTokens = new RegExp(token, 'g'), + reTokens = new RegExp('function \\w+\\(\\)\\{\\"yUglify: preserved comment block\\";\\}', 'g'), ast; try { @@ -63,12 +57,6 @@ exports.jsminify = function (code, config, callback) { code = uglify.split_lines(code, config.max_line_length); } - //First pass with comma (comment inside code somewhere) - code = code.replace(reTokens1, function () { - return '\n' + comments.shift() + '\n'; - }); - - //Second pass without the comma to catch normal comments code = code.replace(reTokens, function () { return '\n' + comments.shift() + '\n'; });