grunt-hashify

Generates a file containing file hashes, copies files with md5 as part of the name, partial updates of hashmap possible.

grunt-hashify

This grunt task iterates over its source files, calculating the MD5 hash of each, then creates a file containing the list of filenames and hashes. It can also create a copy of original filename with hash as part of the name and works with pre-existing hashmap files extending them so partial updates are possible.

This plugin requires Grunt ~0.4.0 Deal with it.

Installation:

npm install grunt-hashify --save-dev

One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-hashify');

In your project's Gruntfile, add a section named hashify to the data object passed into grunt.initConfig().

grunt.initConfig({
  hashify: {
    simple: {
      options: {
        basedir: 'tmp/', // hashmap paths will be relative to this dir, files will be copied to it as well 
        copy: true, // keeps originals 
        hashmap: 'defaults.json' // where to put hashmap. relative to basedir 
      },
      files: [{
        src: 'test/fixtures/style.css', // md5 of the contents goies in hashmap 
        dest: 'style-min-{{hash}}.css', // {{hash}} will be replaced with md5 of the contents of the source 
        key: 'awesome.js' // key to use in the hashmap 
      }, {
        src: 'test/fixtures/script.js',
        dest: 'script-min-{{hash}}.js'
      }]
    }
  },
})