Appends a file's modified UNIX timestamp to a file URL to cache assets
This Gulp plugin is deprecated. Please use https://github.com/sindresorhus/gulp-rev instead for a much more robust solution.
npm install --save-dev gulp-rev-mtime
This example will take the example.html
file and add rev tags to all files that are found in this file, with default options.
var gulp = require('gulp');
var rev = require('gulp-rev-mtime');
gulp.task('rev', function () {
gulp.src('template.html')
.pipe(rev())
.pipe(gulp.dest('.'));
});
<link rel="stylesheet" href="main.min.css"/>
<script src="abc.js"></script>
<script src="def.js"></script>
<link rel="stylesheet" href="main.min.css?v=1393322652000">
<script src="abc.js?v=1393321191000"></script>
<script src="def.js?v=1393321187000"></script>
This example will take the example.html
file and add rev tags to all files that are found in this file with the custom options provided.
var gulp = require('gulp');
var rev = require('gulp-rev-mtime');
gulp.task('rev', function () {
gulp.src('template.html')
.pipe(rev({
'cwd': 'public/assets',
'suffix': 'rev',
'fileTypes': ['css']
}))
.pipe(gulp.dest('.'));
});
<link rel="stylesheet" href="main.min.css"/>
<script src="abc.js"></script>
<script src="def.js"></script>
<link rel="stylesheet" href="main.min.css?rev=1393322652000">
<script src="abc.js"></script>
<script src="def.js"></script>
Type: String
Default: ''
Acts as a working directory for your assets, if your assets are not located in the root folder of the opened file.
Type: String
Default: 'v'
The name of the query parameter for versioning. Example: <script src="def.js?v=1393321187000"></script>
Type: Array
Default: ['js', 'css']
You can choose which files to add version tags to. Use this option if you only want to add version tags to specific file types.
MIT © Thomas Tuts