Grunt File Hash

screenshot of Grunt File Hash

Generate hashed mapping for your static files.

Overview

Grunt File Hash is a powerful tool for managing versioning of static files in web projects, allowing developers to effortlessly create a mapping of file hashes for improved cache management. By generating unique hashes based on file contents, it helps in ensuring that users always receive the most up-to-date resources without the worry of stale caches. This plugin seamlessly integrates with Grunt, a popular task runner in the JavaScript ecosystem, to offer a smooth experience for those already familiar with it or looking to enhance their build processes.

Using Grunt File Hash is straightforward, especially for users who have some experience with Grunt. The plugin supports various options for customizing how hash mappings are generated and saved, making it adaptable for different project needs. Whether you're working on a small personal project or a significant enterprise application, this plugin can greatly streamline your workflow.

Features

  • Customizable Mapping Location: Define the destination for your mapping JSON file with the mappingType option, allowing for organized file management.

  • Flexible Key & Value Structure: Use mappingKeyType and mappingValueType to control how keys and values are generated in the mapping file, tailored precisely to your project's requirements.

  • ETag Support: Automatically create an ETag format for your file versions, helping manage caching effectively by using the etag option.

  • Multiple Hash Algorithms: Choose from various hash algorithms using the algorithm option, depending on your security needs and the version of OpenSSL available.

  • Configurable Hash Length: Set the length of the hash digest through the hashlen option, giving you control over how compact or detailed the hash representation is.

  • Conditional File Renaming: With the rename option, you can rename files to include their hash, helping to bust caches safely and effectively while avoiding potential conflicts.

  • Original File Retention: The keep option allows you to retain original files after renaming, should you need them for other processes or reference.

  • Merge Functionality: The merge option enables automatic merging of hash results into a single mapping file, optimizing your workflow when files change frequently.

grunt
Grunt

Grunt is a popular JavaScript task runner that automates repetitive tasks like minification, compilation, and testing, allowing developers to focus on writing code.