Add version number to js/css/image in HTML
var version = require('gulp-version-number');
gulp.src('src/*.html')
.pipe(version({
... configuration ...
}))
.pipe(gulp.dest('build'));
config
{
/**
* Global version value
* default: %MDS%
*/
'value' : '%MDS%',
/**
* MODE: REPLACE
* eg:
* 'keyword'
* /regexp/ig
* ['keyword']
* [/regexp/ig, '%MD5%']]
*/
'replaces' : [
/**
* {String|Regexp} Replace Keyword/Rules to global value (config.value)
*/
'#{VERSION_REPlACE}#',
/**
* {Array}
* Replace keyword to custom value
* if just have keyword, the value will use the global value (config.value).
*/
[/#{VERSION_REPlACE}#/g, '%TS%']
],
/**
* MODE: APPEND
* Can coexist and replace, after execution to replace
*/
'append' : {
/**
* Parameter
*/
'key' : '_v',
/**
* Whether to overwrite the existing parameters
* default: 0 (don't overwrite)
* If the parameter already exists, as a "custom", covering not executed.
* If you need to cover, please set to 1
*/
'cover' : 0,
/**
* Appended to the position (specify type)
* {String|Array|Object}
* If you set to 'all', will apply to all type, rules will use the global setting.
* If an array or object, will use your custom rules.
* others will passing.
*
* eg:
* 'js'
* ['js']
* {type:'js'}
* ['css', '%DATE%']
*/
'to' : [
/**
* {String} Specify type, the value is the global value
*/
'css',
/**
* {Array}
* Specify type, keyword and cover rules will use the global
* setting, If you need more details, please use the object
* configure.
*
* argument 0 necessary, otherwise passing.
* argument 1 optional, the value will use the global value
*/
['image', '%TS%'],
/**
* {Object}
* Use detailed custom rules to replace, missing items will
* be taken in setting the global completion
* type is necessary, otherwise passing.
*/
{
'type' : 'js',
'attr' : ['src', 'custom-src'] // String or Array, undefined this will use default. css: "href", js: ...
'key' : '_v',
'value' : '%DATE%',
'cover' : 1,
'files': ['build.js', /dependency.js/] // Array [{String|Regex}] of explicit files to append to
}
]
},
/**
* Output to config file
*/
'output' : {
'file' : 'version.json'
}
}
Priority - Covering relations
Version types
append : {
to : [
'???': {
...,
'attr': [...] // string or array
...
},
...
]
}
I was born