gulp-make-css-urlver

0.0.5 • Public • Published

gulp-make-css-urlver

a plugin for gulp.js to replace version for images in css files,the version should be file's md5 or time stamp;

Installation

npm install gulp-make-css-urlver

Usage

var makeUrlVer = require('gulp-make-css-urlver');

gulp.task('stylesheets', function() {
    gulp.src('css/*.css')
        .pipe(makeUrlVer())
        .pipe(gulp.dest('dist'))
});

Options

useDate :make version with time stamp

var makeUrlVer = require('gulp-make-css-urlver');

gulp.task('stylesheets', function() {
    gulp.src('css/*.css')
        .pipe(makeUrlVer({useDate:true}))
        .pipe(gulp.dest('dist'))
});

assetsDir: specify the public directory for correct MD5 calculation in some specific cases

var makeUrlVer = require('gulp-make-css-urlver');

gulp.task('stylesheets', function() {
    gulp.src('css/*.css')
        .pipe(makeUrlVer({
            assetsDir: './public',
            ignore:function(path){
                return path.indexOf('test') >= 0;
            }
        }))
        .pipe(gulp.dest('dist'))
});

Example

before: index.css

/* loading */
.i-loading{width:32px;height:32px;background:url(/images/loading.gif) no-repeat;}    

after: index.css

/* loading */
.i-loading{width:32px;height:32px;background:url(./public/images/loading.gif?v=Je0sUcMH0mhJPWdZdpHzXg%3D%3D) no-repeat}

Package Sidebar

Install

npm i gulp-make-css-urlver

Weekly Downloads

1

Version

0.0.5

License

MIT

Last publish

Collaborators

  • chinatmall