
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
grunt-asset-hash
Advanced tools
Create a folder of asset files that include hashes
This plugin requires Grunt ~1.0.1
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, you may install this plugin with this command:
npm install grunt-asset-hash --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-asset-hash');
In your project's Gruntfile, add a section named asset_hash to the data object passed into grunt.initConfig().
grunt.initConfig({
asset_hash: {
options: {
preserveSourceMaps: false, // Set to true when assets should share the same location as their source map.
assetMap: 'assetmap.json', // A mapping file between assets and their hashed locations. Set to `false` to skip generating.
hashLength: 32, // Number of hex characters in the hash folder. (0 means no hashing is done).
algorithm: 'md5', // Crypto algorithm used to hash the contents.
srcBasePath: '', // The directory prefix to be stripped from the asset map src paths.
destBasePath: '', // The directory prefix to be stripped from the asset map dest paths.
hashType: 'folder', // Defaults to `/$HASH/filename.ext`, but `'file'` will output `filename.$HASH.ext`.
references: [] // Files to replace references in (eg. a CSS file where `image.png` should become `image.$HASH.png`)
},
your_target: {
files: [
{ src: ['assets/**/*'], // A collection of assets to be hashed.
dest: 'hashed' // A folder to contained the hashed assets. Cannot be a file.
}
]
},
},
});
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
FAQs
Create a folder of asset files that include hashes
The npm package grunt-asset-hash receives a total of 2 weekly downloads. As such, grunt-asset-hash popularity was classified as not popular.
We found that grunt-asset-hash demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.