From cfb755d565447fc1af6951f62b2c8ce54265a642 Mon Sep 17 00:00:00 2001 From: Igor Lima Date: Wed, 20 Feb 2013 23:24:24 -0300 Subject: [PATCH] Upgrading from 1.0 to 2.0 uglify version --- Gruntfile.js | 12 +++++------- package.json | 2 +- tasks/minify-lang.js | 11 +++++++---- tasks/minify.js | 10 ++++++---- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 6e65f57aa..1bc22691b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,5 +1,4 @@ -var fs = require('fs'), - uglifyjs = require('uglify-js'); +var fs = require('fs'); module.exports = function (grunt) { @@ -51,13 +50,12 @@ module.exports = function (grunt) { files: minifiedFiles }, options: { - mangle: { - toplevel: true - }, - squeeze: { + fromString: true, + mangle: true, + compress: { dead_code: false }, - codegen: { + output: { ascii_only: true } } diff --git a/package.json b/package.json index 5ba43f7a7..748edb009 100755 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } ], "devDependencies" : { - "uglify-js" : "1.3.4", + "uglify-js" : "latest", "grunt" : "latest", "grunt-contrib-jshint" : "latest", "grunt-contrib-nodeunit" : "latest", diff --git a/tasks/minify-lang.js b/tasks/minify-lang.js index d7b3803d6..e22b74842 100644 --- a/tasks/minify-lang.js +++ b/tasks/minify-lang.js @@ -34,18 +34,21 @@ module.exports = function (grunt) { min, code, comments, - tok; + tok, + result; // Concat specified files. This should really be a single, pre-built (and // linted) file, but it supports any number of files. code = helpers.concat(files, {separator: this.data.separator}); // Add the first comments - tok = uglifyjs.parser.tokenizer(code); - min = showCopyright(tok().comments_before); + //tok = uglifyjs.parse(code); + tok = uglifyjs.parse(code); + min = showCopyright(tok.start.comments_before); // Add the minified source. - min += uglifyjs(wrapFile(code), grunt.config('uglify')); + result = uglifyjs.minify(wrapFile(code), grunt.config('uglify.options')); + min += result.code; grunt.file.write(this.data.dest, min); // Fail task if errors were logged. diff --git a/tasks/minify.js b/tasks/minify.js index a6b09445b..c8ff9c82b 100644 --- a/tasks/minify.js +++ b/tasks/minify.js @@ -15,18 +15,20 @@ module.exports = function (grunt) { min, code, comments, - tok; + tok, + result; // Concat specified files. This should really be a single, pre-built (and // linted) file, but it supports any number of files. code = helpers.concat(files, {separator: this.data.separator}); // Add the first comments - tok = uglifyjs.parser.tokenizer(code); - min = showCopyright(tok().comments_before); + tok = uglifyjs.parse(code); + min = showCopyright(tok.start.comments_before); // Add the minified source. - min += uglifyjs(code, grunt.config('uglify')); + result = uglifyjs.minify(code, grunt.config('uglify.options')); + min += result.code; grunt.file.write(this.data.dest, min); // Fail task if errors were logged. -- 2.47.2