I'm new using Gulp.
I'm wondering how can I concat, uglify and gzip all the js files from a static website using Gulp.
I have a task like this that works but I would like to only include in the dist folder the .gz file and not the combined.js
gulp.task("concat-js", function () {
return gulp.src("./src/js/*.js")
.pipe(concat("combined.min.js"))
.pipe(uglify())
.pipe(gzip())
.pipe(gulp.dest("./build/js"));
});
UPDATE
I encourage you to read the comments. In my case, the problem has been caused by a bad use of gulp-useref, because was generating the file at the end of the build process. Probably noob problem, but hopefully can help anyone.
Thanks in advance...
This should work. Just store the .min file in a temp folder. You can delete that later if you want.
gulp.task("concat-js", function () {
return gulp.src("./src/js/*.js")
.pipe(concat("combined.min.js"))
.pipe(gulp.dest('./temp'))
.pipe(uglify())
.pipe(gzip())
.pipe(gulp.dest("./build/js"));
});
The final file would be "combined.min.js.gz" the only one in build/js. If you don't like that name you could rename it with gulp-rename.