在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):shonny-ua/gulp-rev-collector开源软件地址(OpenSource Url):https://github.com/shonny-ua/gulp-rev-collector开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):gulp-rev-collector
Install$ npm install --save gulp-rev-collector UsageWe can use gulp-rev to cache-bust several assets and generate manifest files for them. Then using gulp-rev-collector we can collect data from several manifest files and replace links to assets in html templates. var gulp = require('gulp');
var rev = require('gulp-rev');
gulp.task('css', function () {
return gulp.src('src/css/*.css')
.pipe(rev())
.pipe(gulp.dest('dist/css'))
.pipe( rev.manifest() )
.pipe( gulp.dest( 'rev/css' ) );
});
gulp.task('scripts', function () {
return gulp.src('src/js/*.js')
.pipe(rev())
.pipe(gulp.dest('dist/js'))
.pipe( rev.manifest() )
.pipe( gulp.dest( 'rev/js' ) );
});
...
var revCollector = require('gulp-rev-collector');
var minifyHTML = require('gulp-minify-html');
gulp.task('rev', function () {
return gulp.src(['rev/**/*.json', 'templates/**/*.html'])
.pipe( revCollector({
replaceReved: true,
dirReplacements: {
'css': '/dist/css',
'/js/': '/dist/js/',
'cdn/': function(manifest_value) {
return '//cdn' + (Math.floor(Math.random() * 9) + 1) + '.' + 'exsample.dot' + '/img/' + manifest_value;
}
}
}) )
.pipe( minifyHTML({
empty:true,
spare:true
}) )
.pipe( gulp.dest('dist') );
}); OptionscollectedManifestType : It is a filename for collecded and merged manifest data in replaceRevedType : You set a flag, replaceReved, which will replace alredy replaced links in template's files. Default value is dirReplacementsType : Specifies a directories replacement set. gulp-rev creates manifest files without any info about directories. E.c. if you use dirReplacements param from Usage example, you get next replacement:
revSuffixType : It is pattern for define reved files suffixes. Default value is '-[0-9a-f]{8,10}-?'. This is necessary in case of e.c. gulp-rename usage. If reved filenames had different from default mask. extMapType : If You use some methods to modify the rev_manifest.json after use gulp-rev and get a result like this:
It means that keys and values in the rev_manifest.json have different ext : less & css. You can define extentions maping rules for correct manifest file processing. Default value is:
Works with gulp-rev-collectorLicense |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论