gulp-css-image-rev
v1.0.4
Published
Gulp extension css files background-image url rev.
Downloads
2
Maintainers
Readme
gulp-css-image-rev
gulp插件,将css里面background-image内的图片加上版本号。
View
before
body{
background: url(../../img/logo.png);
}
after
body{background:url(../../img/logo.png?v=d077a648)}
Usage
npm install gulp-css-image-rev --save-dev
var imageRev = require('gulp-css-image-rev')
gulp.task('less', function() {
return gulp.src('./static/css/**/*.less')
.pipe(imageRev())
.pipe(less()) //请安装相关插件
.pipe(gulp.dest('./static/css'))
});
opt.baseUrl
gulp.task('less', function() {
return gulp.src('./static/css/**/*.less')
.pipe(imageRev({
baseUrl: 'H:\\eduproject\\apps\\www' //使用绝对路径
}))
.pipe(less())
.pipe(cssmin())
.pipe(gulp.dest('./static/css'))
});
});
对应的CSS
body{
background: url(/img/logo.png);
}
Links
- NPM: https://www.npmjs.com/package/gulp-css-image-rev
- Bug:https://github.com/kyo4311/gulp-css-image-rev/issues
- Myblog:http://www.f00sun.com
License
MIT