Last active
December 23, 2015 21:29
-
-
Save archangel-irk/6696847 to your computer and use it in GitHub Desktop.
grunt hash (.md5) checksum file for uglify.
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
uglify: { | |
production: { | |
options: { | |
report: 'min' | |
}, | |
files: [{ | |
expand: true, | |
cwd: '<%= dir.tempJS %>/', | |
src: '*.js', | |
dest: '<%= dir.publicJS %>', | |
rename: function( dest, srcName, options ){ | |
// Calculate md5 hash | |
var | |
fs = require('fs'), | |
crypto = require('crypto'), | |
md5 = crypto.createHash('md5'), | |
pathToFile = grunt.template.process( options.cwd + srcName ), | |
buffer = fs.readFileSync( pathToFile ), | |
fileName = srcName.replace('.js', ''); | |
md5.update( buffer ); | |
var md5Hash = md5.digest('hex'); | |
return dest + '/' + fileName + '.min.' + md5Hash + '.js'; | |
} | |
}] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment