JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5137
  • Score
    100M100P100Q112060F

A gulp plugin for cachebusting files by adding a hash to their name and/or content. Optionally writes a JSON file with mappings from the original filename to the renamed one.

Package Exports

  • gulp-hash

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gulp-hash) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

gulp-hash NPM version Build Status

Gulp plugin for cachebusting files by adding a hash to their name and/or content. Optionally writes a JSON file with mappings from the original filename to the renamed one.

Basic usage

var hash = require('gulp-hash');

// ...

gulp.src('./js/**/*')
    .pipe(hash()) // Add hashes to the files' names
    .pipe(gulp.dest('public/js')) // Write the now-renamed files
    .pipe(hash.manifest('asset-hashes.json')) // Change the stream to the manifest file
    .pipe(gulp.dest('public')); // Write the manifest file

API

hash(options)

Option Default Description
algorithm 'sha1' A hashing algorithm for crypto.createHash or equivalent custom function
hashLength 8 The length of the hash to add to the file's name (substr from the start of the full hash)
template '<%= name %>-<%= hash %><%= ext %>' Format for renaming the files

A more advanced example

See example/example-gulpfile.js for an example for a full gulpfile.