0.2.0 • Published 8 years ago

gulp-res-version v0.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

gulp-res-version

Append file hash as a querystring to the resource references in html and css files.

Installation

npm install gulp-res-version --save-dev

Usage

const resversion = require('gulp-res-version');

gulp.task('prd', () => {
    gulp.src(['./build/**/*.html', './build/**/*.css'])
        .pipe(resversion({
            rootdir: './build/',
            ignore: [/#data$/i]
        }))
        .pipe(gulp.dest('./build/'));
});

Input

<link rel="stylesheet" href="/css/index.css"/>
<script src="/js/common.js"></script>
.bg { background:url(images/bg.png);}

Output

<link rel="stylesheet" href="/css/index.css?v=731fb82c"/>
<script src="/js/common.js?v=be300b8f"></script>
.bg { background:url(images/bg.png?v=4d9e3819);}

Options

rootdir

Type: String

path of root directory, relative to the gulpfile, useful for the absolute paths like '/css/index.css'

ignore

Type: Array

Array of RegExps

qskey

Type: String

Default: 'v'

key name of querystring to append