gulp-asset-cache
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 = ;const imagemin = ;const assetCache = ; gulp;
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:
Name | Type | Default Value | Description |
---|---|---|---|
cacheName | string | './.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