From 5df9eef1b0db8a70514125443323b6bb5b18a65e Mon Sep 17 00:00:00 2001
From: opi <opi@zeropi.net>
Date: Thu, 28 Apr 2016 16:18:07 +0200
Subject: [PATCH] [enh] Add --dev option to gulp tasks tp prevent time
 consuming compression.

---
 README.md        |  2 ++
 src/gulpfile.js  | 12 +++++++++---
 src/package.json |  4 +++-
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 55ac9e49..9d313761 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,8 @@ bower install
 npm install -g gulp
 gulp build
 ```
+Alternatively you can pas the `--dev` option to gulp which improve building
+speed by bypassing compression tasks.
 
 ## Dependencies
 
diff --git a/src/gulpfile.js b/src/gulpfile.js
index 0573b363..608a8748 100644
--- a/src/gulpfile.js
+++ b/src/gulpfile.js
@@ -11,8 +11,14 @@ var concat = require('gulp-concat'),
     cssmin = require('gulp-cssmin'),
     imagemin = require('gulp-imagemin'),
     rename = require('gulp-rename')
+    util = require('gulp-util')
+    gulpif = require('gulp-if')
     ;
 
+// Environment variables
+isDev = (util.env.dev) ? true : false;
+isProduction = !isDev;
+
 // Global build task
 gulp.task('build', [
     'css',
@@ -46,7 +52,7 @@ gulp.task('js', function() {
             'js/yunohost/filters.js',
             'js/yunohost/controllers/*.js',
         ])
-        .pipe(uglify())
+        .pipe(gulpif(isProduction, uglify()))
         .pipe(concat('script.min.js'))
         .pipe(gulp.dest('./dist/js'))
 });
@@ -85,7 +91,7 @@ gulp.task('css', function () {
         .pipe(rename({
             suffix: '.min'
         }))
-        .pipe(cssmin())
+        .pipe(gulpif(isProduction, cssmin()))
         .pipe(gulp.dest('./dist/css'))
 });
 
@@ -104,6 +110,6 @@ gulp.task('css-lint', function() {
 // Images task
 gulp.task('img', function () {
     return gulp.src('img/*')
-        .pipe(imagemin())
+        .pipe(gulpif(isProduction, imagemin()))
         .pipe(gulp.dest('./dist/img'))
 });
diff --git a/src/package.json b/src/package.json
index 3703a28c..cdd430d1 100644
--- a/src/package.json
+++ b/src/package.json
@@ -12,16 +12,18 @@
   },
   "homepage": "https://github.com/YunoHost/yunohost-admin",
   "devDependencies": {
+    "bower": "^1.7.7",
     "gulp": "^3.9.0",
     "gulp-autoprefixer": "^2.3.1",
     "gulp-concat": "^2.6.0",
     "gulp-csslint": "^0.2.0",
     "gulp-cssmin": "^0.1.7",
+    "gulp-if": "^2.0.0",
     "gulp-imagemin": "^2.3.0",
     "gulp-jshint": "^1.11.2",
     "gulp-less": "^3.0.3",
     "gulp-rename": "^1.2.2",
     "gulp-uglify": "^1.2.0",
-    "bower": "^1.7.7"
+    "gulp-util": "^3.0.7"
   }
 }