在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):jgable/gulp-cache开源软件地址(OpenSource Url):https://github.com/jgable/gulp-cache开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):gulp-cacheA temp file based caching proxy task for gulp. Installnpm i -D gulp-cache
# or
yarn add -D gulp-cache Usageimport gulp from 'gulp';
import favicons from 'gulp-favicons';
import srcset from 'gulp-srcset';
import cache from 'gulp-cache';
gulp.task('favicon', () =>
gulp.src('src/favicon.svg')
.pipe(cache(
// Target plugin, the output of which will be cached.
favicons(faviconsConfig),
// Options for `gulp-cache` plugin.
{
// Bucket to store favicons in cache.
name: 'favicons'
}
))
.pipe(gulp.dest('./favicons'))
);
gulp.task('images', () =>
gulp.src('src/**/*.{jpg,png,svg}')
.pipe(cache(
// Target plugin, the output of which will be cached.
srcset(srcsetRules),
// Options for `gulp-cache` plugin.
{
// Bucket to store images in cache.
name: 'images'
}
))
.pipe(gulp.dest('./images'))
); Complex usage exampleimport fs from 'fs';
import gulp from 'gulp';
import jshint from 'gulp-jshint';
import cache from 'gulp-cache';
const jsHintVersion = '2.4.1';
const jshintOptions = fs.readFileSync('.jshintrc');
function makeHashKey(file) {
// Key off the file contents, jshint version and options
return `${file.contents.toString('utf8')}${jshintVersion}${jshintOptions}`;
}
gulp.task('lint', () =>
gulp.src('src/**/*.js')
.pipe(cache(
// Target plugin, the output of which will be cached.
jshint('.jshintrc'),
// Options for `gulp-cache` plugin.
{
key: makeHashKey,
// What on the result indicates it was successful
success(jshintedFile) {
return jshintedFile.jshint.success;
},
// What to store as the result of the successful action
value(jshintedFile) {
// Will be extended onto the file object on a cache hit next time task is ran
return {
jshint: jshintedFile.jshint
};
}
}
))
.pipe(jshint.reporter('default'))
}); API
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论