Making minify vendor a separate task in gulp

Change-Id: I389e2d1184e500473d8d3eb283c4e088fb79d2a1
Signed-off-by: Iftekharul Islam <iislam@us.ibm.com>
diff --git a/gulp_tasks/minifyvendors.js b/gulp_tasks/minifyvendors.js
new file mode 100644
index 0000000..38a17ce
--- /dev/null
+++ b/gulp_tasks/minifyvendors.js
@@ -0,0 +1,42 @@
+
+/*eslint-env node */
+/*global require: true, module: true */
+
+'use strict';
+
+var options = require('../gulp-options.js'),
+    gulp = require('gulp'),
+
+    // Base dependencies
+    clean = require('gulp-clean'),
+    rename = require('gulp-rename'),
+
+    // Classical gulp dependencies
+    uglify = require('gulp-uglify');
+
+var runSequence = require('run-sequence');
+
+gulp.task('minifyvendorjs:clean', function () {
+  return gulp.src(options.bowerFolderPath + '/**/*.min.js', {read: false})
+    .pipe(clean());
+});
+
+gulp.task('minifyvendorjs:minify', function () {
+    return gulp
+        .src(options.bowerFolderPath + '/**/*.js')
+        .pipe(uglify({
+            preserveComments: 'false'
+        })) 
+        .pipe(rename({suffix: '.min'}))
+        .pipe(gulp.dest(function(file) {
+            return file.base;
+        }))
+});
+
+module.exports = function (callback) {
+    return runSequence(
+    	'minifyvendorjs:clean',
+        'minifyvendorjs:minify',
+        callback
+    );
+};
\ No newline at end of file
diff --git a/gulp_tasks/webapp.js b/gulp_tasks/webapp.js
index 6a8b99e..e514543 100644
--- a/gulp_tasks/webapp.js
+++ b/gulp_tasks/webapp.js
@@ -45,18 +45,6 @@
         .pipe(gulp.dest(options.srcFolderPath + '/styles'))
 });
 
-gulp.task('webapp:minifyvendorjs', function () {
-    return gulp
-        .src(options.bowerFolderPath + '/**/*.js')
-        .pipe(uglify({
-            preserveComments: 'false'
-        })) 
-        .pipe(rename({suffix: '.min'}))
-        .pipe(gulp.dest(function(file) {
-            return file.base;
-        }))
-});
-
 // ----- To .temp from app
 gulp.task('webapp:copyjs', function () {
     return gulp.src(options.srcFolderPath + '/**/*.js')
@@ -123,7 +111,6 @@
     return runSequence(
         'webapp:clean',
         'webapp:sasscompile',
-        'webapp:minifyvendorjs',
         [
             'webapp:copyjs',
             'webapp:copycss',