Skip to content

Instantly share code, notes, and snippets.

@jbalducc
jbalducc / gruntfinalize.js
Last active December 11, 2015 10:49
A grunt file to be added in yeoman build task after rjs and rev tasks. input : /<md5>.main.js /<md5>.core.js /package/<md5>.pack1.js output : /<md5>.main.js /<md5>.main.src.js /<md5>.main.js.map /<md5>.core.js /<md5>.core.src.js /<md5>.core.js.map /<md5>.pack1.js /<md5>.pack1.src.js /<md5>.pack1.js.map with main.js containing a map in paths with…
grunt.registerTask('finalize', function () {
var cdnBaseUrl = "//mycdn/scripts/"; // CDN Url where files will be hosted
var pathBase = "./dist/scripts/"; // Local directory where files are already optimized with rjs and already revved (like d4edefds.file.js)
function revmd5(fileContent) {
var hash = crypto.createHash("md5");
hash.update(fileContent);
// 8 chars will be sufficient
return hash.digest('hex').slice(0, 8);
}