My goal is to minify my resource files using gulp 3.9.
I have set up two tasks in my gulpfile as follows:
var gulp = require("gulp"),
concat = require("gulp-concat"),
cssmin = require("gulp-cssmin"),
filter = require('gulp-filter'),
sourcemaps = require('gulp-sourcemaps'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify-es').default,
merge = require("merge-stream"),
del = require("del"),
bundleconfig = require("./bundleconfig.json");
gulp.task("min:js", function () {
var tasks = getBundles(regex.js).map(function (bundle) {
return gulp.src(bundle.inputFiles, { base: ".", sourcemaps: true })
.pipe(filter('**/*.js'))
.pipe(concat(bundle.outputFileName))
.pipe(sourcemaps.write('../maps')) // Shouldn't this create file.js.map file?
.pipe(gulp.dest("."))
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(sourcemaps.write('../maps')) // Shouldn't this create file.min.js.map file?
.pipe(gulp.dest("."));
});
return merge(tasks);
});
gulp.task("min:css", function () {
var tasks = getBundles(regex.css).map(function (bundle) {
return gulp.src(bundle.inputFiles, { base: ".", sourcemaps: true })
.pipe(filter('**/*.css'))
.pipe(concat(bundle.outputFileName))
.pipe(sourcemaps.write('../maps'))
.pipe(gulp.dest("."))
.pipe(cssmin())
.pipe(rename({ suffix: '.min' }))
.pipe(sourcemaps.write('../maps'))
.pipe(gulp.dest("."));
});
return merge(tasks);
});
However, I've encountered an issue where only the .min and regular files are generated, but not the source map file.
Is there a way for Gulp to generate all three files (js, css, and sourcemap) every time the "min:js" and "min:css" tasks run?