gulp-chsi-rev2

1.0.0 • Public • Published

gulp-chsi-rev

基于gulp的插件,静态资源后面添加时间戳作为版本号,达到去缓存的作用。

Installation安装

npm install gulp-chsi-rev2

Usage用法

var gulp = require('gulp');
var chsiRev = require('gulp-chsi-rev2');

gulp.task('rev',function() {
    gulp.src("./test/test.html")
        .pipe(chsiRev())
        .pipe(gulp.dest('./'));
});

Example实例

var gulp = require('gulp');
var chsiRev = require('gulp-chsi-rev2');

gulp.task('rev',['revCss'],function() {
    gulp.src("./test/test.html")
        .pipe(chsiRev({revison: 10000}))
        .pipe(gulp.dest('./dest'));
});

gulp.task('revCss',function () {
    return gulp.src('./test/styles/test.css')
        .pipe(chsiRev(revison: 10000))
        .pipe(gulp.dest('./dest/styles/'))
});
gulp.task('default',['rev']);

before: test.css

body{background:url('../images/bg.png')}

after: test.css

body{background:url("../images/bg.png?v=1482737522923")}

before: test.html

<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title></title>
    <link rel="stylesheet" href="./styles/test.css" type="text/css" />
</head>
<body>
    <div>
        <img src="./images/test.png" />
    </div>
    <script src="./scripts/test.js" type="text/javascript"></script>
</body>
</html>

after: test.html

<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title></title>
    <link rel="stylesheet" href="./styles/test.css?v=1482737522924" type="text/css" />
</head>
<body>
    <div>
        <img src="./images/test.png?v=148273752295" />
    </div>
    <script src="./scripts/test1482737522926.js" type="text/javascript"></script>
</body>
</html>

/gulp-chsi-rev2/

    Package Sidebar

    Install

    npm i gulp-chsi-rev2

    Weekly Downloads

    0

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    10.8 kB

    Total Files

    4

    Last publish

    Collaborators

    • xiaolong120111