When I use gulp-uglify to minify the Javascript files the order gets messed up.
Lets say I have this task working as expected:
var gulp = require('gulp');
var rename = require('gulp-rename');
var gp_concat = require('gulp-concat');
gulp.task('js', function() {
gulp.src([
'./public/bower_components/jquery/dist/jquery.min.js',
'./public/js/functions.js',
])
.pipe(gp_concat('combined.js'))
.pipe(gulp.dest(path.js + '/dist'))
});
Adding the uglify line to it changes the order of the jquery
and functions
files and places functions.js
above jquery
.
var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var gp_concat = require('gulp-concat');
gulp.task('js', function() {
gulp.src([
'./public/bower_components/jquery/dist/jquery.min.js',
'./public/js/functions.js',
])
.pipe(gp_concat('combined.js'))
.pipe(gulp.dest(path.js + '/dist'))
.pipe(uglify({
preserveComments: 'license'
}))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(path.js + '/dist'))
});
Any possible solution to it ? Of course, functions.js is just a plane Javascript file with funtions in it and are not wrapped in an IIFE.