Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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.