Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/outluch/gulp-rev-hash
Keeps a file's hash in file's links to your assets. For automatic cache updating purpose.
https://github.com/outluch/gulp-rev-hash
Last synced: 18 days ago
JSON representation
Keeps a file's hash in file's links to your assets. For automatic cache updating purpose.
- Host: GitHub
- URL: https://github.com/outluch/gulp-rev-hash
- Owner: outluch
- Fork: true (thomastuts/gulp-rev-mtime)
- Created: 2014-03-17T16:32:11.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-16T01:14:51.000Z (about 10 years ago)
- Last Synced: 2024-09-26T03:30:25.571Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 201 KB
- Stars: 18
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
gulp-rev-hash
=============> Keeps a file's hash in file's links to your assets. For automatic cache updating purpose.
## Install
```
npm install --save-dev gulp-rev-hash
```## Examples
### Default
This example will keep links to assets in `layouts/_base.ect` ECT template always updated on assets change. If your assets are not in root of your project, add assetsDir option, like this: `.pipe(revHash({assetsDir: 'public'}))`
```js
var gulp = require('gulp');
var revHash = require('gulp-rev-hash');gulp.task('rev-hash', function () {
gulp.src('layouts/_base.ect')
.pipe(revHash())
.pipe(gulp.dest('layouts'));
});
```#### Input:
```html
```
#### Output:
```html
```
Main idea is that your template always contains a link with hash. So, if you use preprocessing for your assets (compass, less, stylus, coffeescript, dart), if you accidentally added empty line or empty item to your source, preprocessor will generate the same file and your cached resource will have the same hash. And your clients will not redownload file.
### Custom options
```
assetsDir: 'public'
```Path to assets in your project
### Known issues
* Assets links in template should be on new line each.