Skip to content

wzc0x0/gulp-asset-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

gulp-asset-time

a plugin for gulp.js to replace file's name by adding current time
fork from gulp-asset-rev

Installation

npm install gulp-asset-time -D

Usage

var gulp = require('gulp');
var assetRev = require('gulp-asset-time');

gulp.task('rev',function() {
    gulp.src("./test/test.html")
        .pipe(assetRev())
        .pipe(gulp.dest('./'));
});
var gulp = require('gulp');
var assetRev = require('./index.js');

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

gulp.task('revCss',function () {
    return gulp.src('./test/styles/test.css')
        .pipe(assetRev())
        .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?v=19700101010.png"}

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?v=19700101010.css" type="text/css" />
</head>
<body>
    <div>
        <img src="./images/test?v=19700101010.png" />
    </div>
    <script src="./scripts/test?v=19700101010.js" type="text/javascript"></script>
</body>
</html>

About

add current time on assets by gulp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published