gulp-version-filename
v2.0.0
Published
Pull versioning from a file and add it to the filename.
Downloads
76
Maintainers
Readme
Gulp Version Filename
Takes the version number from within a file and adds it to the filename. This is specifically useful for pipelines outputting JS or CSS files. Allows for versioning controlled by you, instead of a hash, allowing for the use of human understandable sequencing (such as semver).
eg: myjslibrary-2.1.0.min.js
How to Use
Install module.
npm i gulp-version-filename
Somewhere Within Your CSS/JS/etc File
/**
* My File
* @version 8.12.12
*/
gulpfile.js
var filever = require('gulp-version-filename');
/**
* Takes the version number and adds it to the filename
*/
gulp.task('rename', function() {
return gulp.src(['newcssfile.css'])
.pipe(filever())
.pipe(gulp.dest('dist'));
});
gulp rename
You should now have
dist/newcssfile-8.12.12.css
Options
key
Pass to change the version variable tag within the file, defaults to 'version'
silent
Pass to suppress errors thrown if the version parameter is not found within a file.
gulp.task('rename', function() {
return gulp.src(['*.css', '*.js'])
.filever({
key: 'package', // Searches for @package
silent: true // Suppress errors if file is missing @package
})
.pipe(gulp.dest('dist'));
});