Gulp minify multiple js files to one

This plugin will help gulp-concat.

Usage:

var concat = require('gulp-concat');

gulp.task('scripts', function() {
  gulp.src(['./lib/file3.js', './lib/file1.js', './lib/file2.js'])
    .pipe(concat('all.js'))
    .pipe(uglify())
    .pipe(gulp.dest('./dist/'))
});

Instead of going through a lots of tricky things, I recommend you getting laravel-elixir. It is compiling sass, less, babel, coffescript and even adding something that you want with not just JavaScript but also with css. All the code that you will need will be:

var gulp = require('gulp');
var elixir = require('laravel-elixir');

elixir(function(mix) {
    mix.scripts(['app.js', 'controllers.js', 'sweetalert.js'], 'public/js/all.js');
    mix.styles(['normalize.css', 'app.css', 'sweetalert.css'], 'public/css/all.css')
});

Lets try gulp-concat-util for joining scripts. It's similar to concat, but have some helpers to glue files. There is special helper to concatinate scripts.

var concat = require('gulp-concat-util');

gulp.task('scripts', function() {
  gulp.src(['./lib/file3.js', './lib/file1.js', './lib/file2.js'])
    .pipe(concat.scripts('all.js'))
    .pipe(uglify())
    .pipe(gulp.dest('./dist/'))
});