0.0.7 • Published 10 years ago

grunt-md5vel v0.0.7

Weekly downloads
1
License
-
Repository
github
Last release
10 years ago

grunt-md5vel

Grunt plugin for generating MD5 filenames.

Getting Started

Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-md5vel

Then add this line to your project's grunt.js gruntfile:

grunt.loadNpmTasks('grunt-md5vel');

Then specify what files you want to generate an md5 filename in your config:

grunt.initConfig({
  md5vel: {
    compile: {
      files: [{
        'dest/folder/': 'src/file'
      }],
      options: {
        /** `prefix`, `suffix`, `hash`, `extension`, `template` accept `string`, `function` and `object`
         * @type {String, Object, Function, void}
         * Where object is keyed by the original value, such that the destinations file extension would become `new.dist.js` with the option `{ 'js': 'new.dist.js' }` for `script.js`
         */
        prefix: '', // defaults to current basename of file,
        hash: function(hash){
          return hash.substr(0,8)
        },
        suffix: '',
        extension: 'ext' || {
          'js': 'my.js',
          'css': 'our.css'
        } 
        template: _.template(
          "<%= _.filter([prefix, hash, suffix]).join(delimiter) %>" +
          "<%= extension? '.':'' %><%= extension %>")

        /**
         * Called before determing the filename
         * @param  {Object} filename Contains filename compontents { 
         *                              prefix 
         *                              hash
         *                              suffix
         *                              extension 
         *                              template 
         *                            }
         */
        beforeEach: function (filename, options){}

        /**
         * A callback after each file is written describing the change
         * @param  {Object} fileChange {
         *                               newPath
         *                               oldPath
         *                               content
         *                             }
         */
        afterEach: function (fileChange) {},

        /**
         * A callback after all files are written with a summary of writes
         * @param  {[Object]} fileChanges [{newPath, oldPath, content}, …}]
         */
        after: function (fileChanges) {}

      }
    }
  }
});
0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago