Registry / devops / grunt-hash

grunt-hash

JSON →
library0.5.0jsnpmunverified

grunt-hash is a Grunt plugin that appends a unique hash (MD5 or custom) to filenames for cache busting. It generates mapping files for server-side asset lookup. Stable version 0.5.0, last released in 2013. Requires Grunt 0.4.x. Differentiators: simple configuration, supports custom hash functions, and outputs mapping JSON. No longer actively maintained; consider alternatives like gulp-rev or webpack.

npm install grunt-hash
INSTALL
IMPORT
SIG · GRUNT-HASH
G
grunt-hash
devopsjavascriptv0.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

grunt-hash task
grunt.loadNpmTasks('grunt-hash');
require('grunt-hash');
Grunt tasks are loaded via loadNpmTasks, not direct require.
hash config
grunt.initConfig({ hash: { options: {}, js: { src: '...', dest: '...' } } });
grunt.initConfig({ hash: { src: '...', dest: '...' } });
Missing target (e.g., js, css) configuration block.
hashFunction option
hashFunction: function(source, encoding) { return require('crypto').createHash('sha1').update(source, encoding).digest('hex'); }
hashFunction: 'sha1'
Must be a function, not a string.

Gruntfile configuration for grunt-hash with custom hash function, mapping output, and JS/CSS targets.

module.exports = function(grunt) { grunt.initConfig({ hash: { options: { mapping: 'dist/assets.json', srcBasePath: 'src/', destBasePath: 'dist/', flatten: false, hashLength: 8, hashFunction: function(source, encoding) { return require('crypto').createHash('md5').update(source, encoding).digest('hex'); } }, js: { src: 'src/**/*.js', dest: 'dist/js/' }, css: { src: 'src/**/*.css', dest: 'dist/css/' } } }); grunt.loadNpmTasks('grunt-hash'); grunt.registerTask('default', ['hash']); };
Debug
Known issues
deprecatedPackage is unmaintained since 2013. Use at your own risk. Consider gulp-rev or webpack for cache busting.
fix
Migrate to gulp-rev or webpack chunk hashing.
affects: >=0.5.0
breakingRequires Grunt 0.4.x. Not compatible with Grunt 1.x without compatibility layer.
fix
Use grunt-cli with Grunt 0.4.x or wrap task.
affects: >=0.2.0
gotchaIf dest folder does not exist, the task may fail silently or not create output.
fix
Ensure dest directories exist before running grunt-hash.
affects: *
gotchaMapping file is overwritten on each run; no incremental merge.
fix
Backup mapping file if needed.
affects: *
Errors
Common errors & fixes
Warning: Task "hash" not found. Use --force to continue.
Gruntfile missing grunt.loadNpmTasks('grunt-hash') line.
fix
Add grunt.loadNpmTasks('grunt-hash'); after initConfig.
Fatal error: Unable to find Grunt plugin "grunt-hash"
Package not installed locally.
fix
Run npm install grunt-hash --save-dev
TypeError: hashFunction is not a function
hashFunction option set to a string instead of a function.
fix
Set hashFunction to a function returning hash string.
Upgrade
Version history
0.5.0latest on npm
Audit
Dependencies
gruntrequiredpeer dependency for Grunt tasks
Agent activity
8 hits · last 30 days
node
8
Resources
grunt-hash — npm install grunt-hash · libregistry