In a gulp task, I want to include a javascript file and inserting version within the file name.
Basically, in my task, I want to copy :
./node_modules/bootstrap-sass/assets/javascripts/bootstrap.js
to./dist/js/bootstrap.3.3.7.js
./node_modules/bootstrap-sass/assets/javascripts/bootstrap.min.js
to./dist/js/bootstrap.3.3.7.min.js
I defined this task:
var gulp = require('gulp');
var rename = require('gulp-rename');
var bsInfo = require('./node_modules/bootstrap-sass/package.json');
...
gulp.task('assets:js', function () {
return gulp.src(['./node_modules/bootstrap-sass/assets/javascripts/bootstrap.js', './node_modules/bootstrap-sass/assets/javascripts/bootstrap.min.js'])
.pipe(rename(function (path) { path.basename += "." + bsInfo.version; }))
.pipe(gulp.dest('./dist/js'));
});
However, the generated file names are:
- bootstrap.3.3.7.js (correct)
- bootstrap.min.3.3.7.js (incorrect, min is before the version number).
How can I write my task to output the correct file name ?