gulp-data
gulp-data copied to clipboard
Please provide a cache option
Hello! I'm using this plugin to add some data for gulp-swig.
This plugin has a cache for readed files? Why when I changed data files, same content in return like first time?
I found answer, it's require() cache.
My solution:
gulp.task('json-test', function() {
return gulp.src('./examples/test1.html')
.pipe(data(function(file) {
var json = './examples/' + path.basename(file.path) + '.json';
delete require.cache[require.resolve(json)];
return require(json);
}))
.pipe(swig())
.pipe(gulp.dest('build'));
});
@bolord thanks for coming back and posting your solution, as I was looking a way to clean the cache on gulp-data.