gsv

gulp-src-version

网页静态资源增加版本号

Showing:

Popularity

Downloads/wk

4

GitHub Stars

0

Maintenance

Last Commit

4yrs ago

Contributors

2

Package

Dependencies

1

Size (min+gzip)

21.7KB

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

gulp-src-version


根据文件MD5值修改Html/Css中的src增加版本信息

Install

npm i gulp-src-version --save-dev

options

{
    rootPath:        指定根目录 //默认为空
    verStr:          固定版本号 //默认为空  输入为字符串
    replaceStrReg:   替换字符串 //默认为空  输入为正则表达式
    verConnecter:    默认链接符 //默认为 `?v=` 连接符
    hashLen:         版本号长度 //默认[7]位 输入为正整数
    resolvePath:     自定义方法 //回调src
}

show html

<img src="img/one.jpg?v=28bd4f6" />
<img src="img/two.jpg?v=991878c" />

<script src="js/one.js?v=5ef297b"></script>
<script src="js/two.js?v=10ba7be"></script>

show gulpfile.js

var gulp = require('gulp'),
    gulp_src_version = require('gulp-src-version');

gulp.task('revHtml', function(){
    gulp.src('./**/*.html')
        .pipe(gulp_src_version())
        .pipe(gulp.dest('./dest'));
});

gulp.task('default', ['revHtml']);

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100