src: {
options: {
banner: '<%= banner %>',
+ preBundleCB: function() {
+ var fs = require('fs');
+ var UglifyJS = require('uglify-js');
+ var files = {};
+ UglifyJS.FILES.forEach(function(file) {
+ files[file] = fs.readFileSync(file, 'utf8');
+ });
+ fs.writeFileSync('./dist/uglify.js', UglifyJS.minify(files, {
+ compress: false,
+ mangle: false,
+ wrap: 'exports'
+ }).code);
+ },
+ postBundleCB: function(err, src, next) {
+ require('fs').unlinkSync('./dist/uglify.js');
+ next(err, src);
+ },
require: [
+ './dist/uglify.js:uglify-js',
'./src/htmlminifier.js:html-minifier'
]
},
},
"dependencies": {
"camel-case": "3.0.x",
- "clean-css": "4.0.x",
+ "clean-css": "4.1.x",
"commander": "2.9.x",
"he": "1.1.x",
"ncname": "1.0.x",
"param-case": "2.1.x",
"relateurl": "0.2.x",
- "uglify-js": "~2.8.22"
+ "uglify-js": "3.0.x"
},
"devDependencies": {
"grunt": "1.0.x",
"grunt-browserify": "5.0.x",
- "grunt-contrib-uglify": "2.3.x",
+ "grunt-contrib-uglify": "3.0.x",
"gruntify-eslint": "3.1.x",
"phantomjs-prebuilt": "2.1.x",
- "qunitjs": "2.x",
- "uglify-to-browserify": "1.0.x"
+ "qunitjs": "2.x"
},
"benchmarkDependencies": {
"brotli": "1.3.x",
if (typeof minifyJS !== 'object') {
minifyJS = {};
}
- minifyJS.fromString = true;
(minifyJS.parse || (minifyJS.parse = {})).bare_returns = false;
options.minifyJS = function(text, inline) {
var start = text.match(/^\s*<!--.*/);
var code = start ? text.slice(start[0].length).replace(/\n\s*-->\s*$/, '') : text;
- try {
- minifyJS.parse.bare_returns = inline;
- code = UglifyJS.minify(code, minifyJS).code;
- if (/;$/.test(code)) {
- code = code.slice(0, -1);
- }
- return code;
- }
- catch (err) {
- options.log(err);
+ minifyJS.parse.bare_returns = inline;
+ var result = UglifyJS.minify(code, minifyJS);
+ if (result.error) {
+ options.log(result.error);
return text;
}
+ return result.code.replace(/;$/, '');
};
}