md5ify
Synchronously return the md5 hex hash of a file path through either Node or browserify.
Useful, for example, for keeping unique IDs of particular files based on their contents in order to cache external resources better.
Usage
md5ify(filename)
Returns a hash of the file's contents at filename
.
const md5ify =const hash =console
md5ify
with browserify
The above works in Node, but you can easily make it work
in browserify too by adding it as a transform. This works
similarly to brfs and
determines the file's hash at build time. Simply include
it in your list of browserify.transforms
in your project's
package.json
file:
Alternatively, you may specify the transform through
browserify's command-line interface using the -t
flag:
browserify index.js -t md5ify/transform
Or through browserify's Node API using the .transform
method:
const browserify =const bundler =bundlerbundler
License
MIT. See LICENSE.md for details.