[enh] Add --dev option to gulp tasks tp prevent time consuming compression.

This commit is contained in:
opi 2016-04-28 16:18:07 +02:00
parent 3595b6c5af
commit 5df9eef1b0
3 changed files with 14 additions and 4 deletions

View file

@ -28,6 +28,8 @@ bower install
npm install -g gulp npm install -g gulp
gulp build gulp build
``` ```
Alternatively you can pas the `--dev` option to gulp which improve building
speed by bypassing compression tasks.
## Dependencies ## Dependencies

View file

@ -11,8 +11,14 @@ var concat = require('gulp-concat'),
cssmin = require('gulp-cssmin'), cssmin = require('gulp-cssmin'),
imagemin = require('gulp-imagemin'), imagemin = require('gulp-imagemin'),
rename = require('gulp-rename') 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 // Global build task
gulp.task('build', [ gulp.task('build', [
'css', 'css',
@ -46,7 +52,7 @@ gulp.task('js', function() {
'js/yunohost/filters.js', 'js/yunohost/filters.js',
'js/yunohost/controllers/*.js', 'js/yunohost/controllers/*.js',
]) ])
.pipe(uglify()) .pipe(gulpif(isProduction, uglify()))
.pipe(concat('script.min.js')) .pipe(concat('script.min.js'))
.pipe(gulp.dest('./dist/js')) .pipe(gulp.dest('./dist/js'))
}); });
@ -85,7 +91,7 @@ gulp.task('css', function () {
.pipe(rename({ .pipe(rename({
suffix: '.min' suffix: '.min'
})) }))
.pipe(cssmin()) .pipe(gulpif(isProduction, cssmin()))
.pipe(gulp.dest('./dist/css')) .pipe(gulp.dest('./dist/css'))
}); });
@ -104,6 +110,6 @@ gulp.task('css-lint', function() {
// Images task // Images task
gulp.task('img', function () { gulp.task('img', function () {
return gulp.src('img/*') return gulp.src('img/*')
.pipe(imagemin()) .pipe(gulpif(isProduction, imagemin()))
.pipe(gulp.dest('./dist/img')) .pipe(gulp.dest('./dist/img'))
}); });

View file

@ -12,16 +12,18 @@
}, },
"homepage": "https://github.com/YunoHost/yunohost-admin", "homepage": "https://github.com/YunoHost/yunohost-admin",
"devDependencies": { "devDependencies": {
"bower": "^1.7.7",
"gulp": "^3.9.0", "gulp": "^3.9.0",
"gulp-autoprefixer": "^2.3.1", "gulp-autoprefixer": "^2.3.1",
"gulp-concat": "^2.6.0", "gulp-concat": "^2.6.0",
"gulp-csslint": "^0.2.0", "gulp-csslint": "^0.2.0",
"gulp-cssmin": "^0.1.7", "gulp-cssmin": "^0.1.7",
"gulp-if": "^2.0.0",
"gulp-imagemin": "^2.3.0", "gulp-imagemin": "^2.3.0",
"gulp-jshint": "^1.11.2", "gulp-jshint": "^1.11.2",
"gulp-less": "^3.0.3", "gulp-less": "^3.0.3",
"gulp-rename": "^1.2.2", "gulp-rename": "^1.2.2",
"gulp-uglify": "^1.2.0", "gulp-uglify": "^1.2.0",
"bower": "^1.7.7" "gulp-util": "^3.0.7"
} }
} }