diff --git a/gulpfile.js b/gulpfile.js
index 0a557d29d8d446812963df5ed5a8ad559e39e7ed..cf5ab46e95982462bb87b7ff7a6ebfa04037e710 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -637,12 +637,12 @@ function webCleanUnusedDirectories() {
 
   let patterns = [
     wwwPath + '/templates',
-    wwwPath + '/js',
     wwwPath + '/plugins'
   ];
 
   if (enableUglify) {
     patterns = patterns.concat([
+      wwwPath + '/js',
       wwwPath + '/css',
       wwwPath + '/dist',
       wwwPath + '/lib/*',
@@ -659,12 +659,14 @@ function webCleanUnusedDirectories() {
   }
   else {
     patterns = patterns.concat([
+      wwwPath + '/js/*',
+      '!' + wwwPath + '/js/vendor',
       wwwPath + '/dist_css',
       wwwPath + '/dist_js'
     ]);
   }
 
-  return gulp.src(patterns, {read: false})
+  return gulp.src(patterns, {read: false, allowEmpty: true})
     //.pipe(debug({title: 'deleting '}))
     .pipe(clean());
 }