Created
May 11, 2015 07:54
-
-
Save nqbao/1b7fafd9831cf5ea1393 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (self._minifyTogether) { | |
var sources = _.map(self.js, function (file) { | |
return file.contents('utf8'); | |
}); | |
buildmessage.enterJob({title: "minifying"}, function () { | |
allJs = _minify(minifiers.UglifyJS, '', sources, minifyOptions).code; | |
}); | |
self.js = [new File({ info: 'minified js', data: new Buffer(allJs, 'utf8') })]; | |
self.js[0].setUrlToHash(".js"); | |
} else { | |
minifyOptions.compress.unused = false; | |
minifyOptions.compress.dead_code = false; | |
var groups = {"packages": [], "templates": [], "main": []}; | |
_.each(self.js, function(file) { | |
if (/packages/.test(file.info)) { | |
groups['packages'].push(file); | |
} | |
else if (/template\./.test(file.info)) { | |
groups['templates'].push(file); | |
} | |
else { | |
groups['main'].push(file); | |
} | |
}); | |
self.js = []; | |
for (var group in groups) { | |
allJs = buildmessage.forkJoin({title: "minifying" }, groups[group], function (file) { | |
var source = file.contents('utf8'); | |
return _minify(minifiers.UglifyJS, file.info, source, minifyOptions).code; | |
}).join("\n\n"); | |
var file = new File({ info: 'minified ' + group + ' js', data: new Buffer(allJs, 'utf8') }); | |
file.setUrlToHash("." + group + ".js"); | |
self.js.push(file); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment