File revving
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 3 commits ahead, 67 commits behind yeoman:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Static asset revisioning through file content hash

This is a fork of with some difference:

  • Adding suffix ?v={{filever}} to grunt.filerev (instead of file renaming) for the next usemin processing

Getting Started

If you haven't used grunt before, be sure to check out the Getting Started guide, as it explains how to create a gruntfile as well as install and use grunt plugins. Once you're familiar with that process, install this plugin with this command:

npm install --save-dev grunt-filever


This task will revision your files based on its contents. You should then set the files to expire far into the future for better caching and it will only update when it changes.


  filerev: {
    options: {
      encoding: 'utf8',
      algorithm: 'md5',
      length: 8
    images: {
      src: 'img/**/*.{jpg,jpeg,gif,png,webp}'



Type: String
Default: 'utf8'

The file encoding.


Type: String
Default: 'md5'

algorithm is dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are 'sha1', 'md5', 'sha256', 'sha512', etc. On recent releases, openssl list-message-digest-algorithms will display the available digest algorithms.


Type: Number
Default: 8

The number of characters of the file hash to prefix the file name with.


It will overwrite the src files if you don't specify a dest:

filerev: {
  images: {
    src: ['img1.png', 'img2.png'],
    dest: 'tmp'


The task keeps track of all files created and its sources in a summary that is exposed through the grunt.filerev.summary object. It can be used to replace references to the revved files or debugging purposes. The key of the object is the original filename, the value is the new revved path.

For a configuration like this

filerev: {
  images: {
    src: ['img1.png', 'img2.png'],
    dest: 'tmp'

the content grunt.filerev.summary could look like that:

  'img1.png': 'tmp/img1.png?v=59bcc3ad',
  'img2.png': 'tmp/img2.png?v=060b1aa6'


BSD license and copyright Google