gulp-checksum
Generates checksums out of static resources and renames the files accordingly - this makes a unique filename for each version of the file so that HTTP headers can be set to cache forever.
Can also update references to the resources with checksum using the references()
call, just make sure that all calls to resources()
is done before. gulp-checksum assumes HTML, and so looks for references in href
and src
attributes.
gulp-checksum correctly handles relative URLs, even if multiple resources in the tree have the same filename.
Basic Example
var gulp = ;var checksum = ; gulp; gulp;
Example with SASS, source maps and Mustache, changing the output paths on the way
gulp-checksum stores references as absolute paths internally, so it's important to call resources()
and references()
at the same point in the chain, so that paths will still match up. Also note that sourcemaps.write()
is called after the rename, so that names will match properly.
Source SASS files are in a scss/
path but will be output under css/
and the result from Mustache will have new file ending .html
.
var gulp = ;var path = ;var checksum = ;var sass = ;var rename = ;var mustache = ;var sourcemaps = ; gulp; gulp;
Test
npm test