1.1.5 • Published 7 years ago

gulp-asset-cache v1.1.5

Weekly downloads
31
License
MIT
Repository
github
Last release
7 years ago

gulp-asset-cache

Build Status Coverage Status bitHound Dependencies

A disk based caching task for gulp. This plugin was built mainly to deal with the issues around having no dist directory and wanting to prevent image/video compression from happening multiple times on larger teams. If you do have the luxury of a src/dist file structure I recommend gulp-changed or gulp-newer as they easily integrate with that setup.

Installation

Install package with NPM and add it to your development dependencies:

npm install gulp-asset-cache

Example

Below is a basic example of using the cache to manage image minification with the imagemin module.

const gulp = require('gulp');
const imagemin = require('gulp-imagemin');
const assetCache = require('gulp-asset-cache');

gulp.task('images', function() {
  return gulp.src('./images/*.{jpg,png,jpeg,gif,svg}')
    // Specify the location and name of the cache file
    .pipe(assetCache.filter('./images/.image-cache'))
    .pipe(imagemin({
      verbose: true
    }))
    .pipe(gulp.dest('./images/'))
    .pipe(assetCache.cache());
});

This will create a cache file named .image-cache of all files passed through the pipeline to be excluded from subsequent runs. If a file that has been cached is updated, the cache will recognize this and pass the file through to update it in the cache.

API

assetCache.filter(cacheName)

Generate a file that will contain all of the information related to the cache. If a file already exists, it will filter out the items within the cache from the stream.

Parameters:

NameTypeDefault ValueDescription
cacheNamestring'./.asset-cache'The name and location of where the cache file will be saved.

assetCache.cache()

Create or update the currently streamed cache file.

License

MIT

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago