I'm trying to do the following in Gulp: 1) Minify JS files from a specified folder to a folder called 'dist'. 2) Append '.min' to the minified filenames. 3) Provide a sourcemap to the minified files and place them in a folder called 'maps'.
I am using 'gulp-uglify', 'gulp-rename' and 'gulp-sourcemaps'.
Here is what I have:
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');
gulp.task('compress', function () {
gulp.src('src/*.js')
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write('../maps'))
.pipe(gulp.dest('dist'));
});
Everything works as intended, except the map files also get '.min' appended to them. How do I restrict the renaming to only occur in the dist folder?