diff --git a/resources/gulp/components/account.js b/resources/gulp/components/account.js index 2eb0d99d4f..2002255605 100644 --- a/resources/gulp/components/account.js +++ b/resources/gulp/components/account.js @@ -1,6 +1,7 @@ var gulp = require('gulp'); var config = require('../config.js'); var utils = require('../utils.js'); +var debugMode = false; gulp.task('copy-account-images', function(){ return gulp.src([config.paths.src + 'account/images/**/*']) @@ -9,7 +10,7 @@ gulp.task('copy-account-images', function(){ gulp.task('build-account-css', function(){ return utils.buildCssGroup([ config.paths.src + 'account/styles/main.scss' - ], 'account', 'account/css/'); + ], 'account', 'account/css/', debugMode); }); gulp.task('build-account-js', function(){ @@ -17,17 +18,20 @@ gulp.task('build-account-js', function(){ config.paths.vendors + 'requirejs/require.js', config.paths.src + 'account/js/account.js' ]; - return utils.buildJsGroup(accountGroup, 'account', 'account/js'); + return utils.buildJsGroup(accountGroup, 'account', 'account/js', debugMode); }); gulp.task('watch-account-js', function() { + debugMode = true; return gulp.watch(config.paths.src + 'account/**/*.js', ['build-account-js']); }); gulp.task('watch-account-css', function() { + debugMode = true; gulp.watch(config.paths.src + 'account/**/*.scss', ['build-account-css']); }); gulp.task('build-account', ['copy-account-images', 'build-account-css'], function(){ + debugMode = false; return gulp.start('build-account-js'); }); \ No newline at end of file diff --git a/resources/gulp/components/admin.js b/resources/gulp/components/admin.js index 4b0dea0efa..9e22c39f0e 100644 --- a/resources/gulp/components/admin.js +++ b/resources/gulp/components/admin.js @@ -1,6 +1,7 @@ var gulp = require('gulp'); var config = require('../config.js'); var utils = require('../utils.js'); +var debugMode = false; gulp.task('copy-admin-images', function(){ return gulp.src([config.paths.src + 'admin/images/**/*']) @@ -9,7 +10,7 @@ gulp.task('copy-admin-images', function(){ gulp.task('build-admin-css', function(){ return utils.buildCssGroup([ config.paths.src + 'admin/styles/main.scss' - ], 'admin', 'admin/css/'); + ], 'admin', 'admin/css/', debugMode); }); gulp.task('build-admin-js', function(){ @@ -22,17 +23,20 @@ gulp.task('build-admin-js', function(){ config.paths.dist + 'scripts/apps/admin/require.config.js', config.paths.dist + 'scripts/apps/admin/main/main.js' ]; - utils.buildJsGroup(adminGroup, 'admin', 'admin/js'); + utils.buildJsGroup(adminGroup, 'admin', 'admin/js', debugMode); }); gulp.task('watch-admin-js', function() { + debugMode = true; return gulp.watch(config.paths.src + 'admin/**/*.js', ['build-admin-js']); }); gulp.task('watch-admin-css', function() { + debugMode = true; gulp.watch(config.paths.src + 'admin/**/*.scss', ['build-admin-css']); }); gulp.task('build-admin', ['copy-admin-images', 'build-admin-css'], function(){ + debugMode = false; return gulp.start('build-admin-js'); }); \ No newline at end of file diff --git a/resources/gulp/components/authentication.js b/resources/gulp/components/authentication.js index 79c32f582d..271d703333 100644 --- a/resources/gulp/components/authentication.js +++ b/resources/gulp/components/authentication.js @@ -1,6 +1,7 @@ var gulp = require('gulp'); var config = require('../config.js'); var utils = require('../utils.js'); +var debugMode = false; gulp.task('copy-authentication-images', function(){ return gulp.src([config.paths.src + 'authentication/images/**/*']) @@ -9,7 +10,7 @@ gulp.task('copy-authentication-images', function(){ gulp.task('build-authentication-css', function(){ return utils.buildCssGroup([ config.paths.src + 'authentication/styles/main.scss' - ], 'authentication', 'authentication/css/'); + ], 'authentication', 'authentication/css/', debugMode); }); gulp.task('build-authentication-js', function(){ @@ -17,17 +18,20 @@ gulp.task('build-authentication-js', function(){ config.paths.vendors + 'requirejs/require.js', config.paths.dist + 'scripts/apps/login/home/config.js' ]; - return utils.buildJsGroup(authenticationGroup, 'authentication', 'authentication/js'); + return utils.buildJsGroup(authenticationGroup, 'authentication', 'authentication/js', debugMode); }); gulp.task('watch-authentication-js', function() { + debugMode = true; return gulp.watch(config.paths.src + 'authentication/**/*.js', ['build-authentication-js']); }); gulp.task('watch-authentication-css', function() { + debugMode = true; gulp.watch(config.paths.src + 'authentication/**/*.scss', ['build-authentication-css']); }); gulp.task('build-authentication', ['copy-authentication-images', 'build-authentication-css'], function(){ + debugMode = false; return gulp.start('build-authentication-js'); }); \ No newline at end of file diff --git a/resources/gulp/components/common.js b/resources/gulp/components/common.js index b822d817ce..65d9093d78 100644 --- a/resources/gulp/components/common.js +++ b/resources/gulp/components/common.js @@ -1,6 +1,7 @@ var gulp = require('gulp'); var config = require('../config.js'); var utils = require('../utils.js'); +var debugMode = false; gulp.task('copy-common-images', function(){ return gulp.src([config.paths.src + 'common/images/**/*']) @@ -20,7 +21,7 @@ gulp.task('build-common-font-css', ['copy-common-fonts'],function(){ gulp.task('build-common-css', ['build-common-font-css'],function(){ return utils.buildCssGroup([ config.paths.src + 'common/styles/main.scss' - ], 'common', 'common/css/') + ], 'common', 'common/css/', debugMode) }); gulp.task('build-common-js', function(){ @@ -42,17 +43,20 @@ gulp.task('build-common-js', function(){ config.paths.vendors + 'swfobject/swfobject/swfobject.js', // @TODO: should be moved away (embed-bundle) config.paths.dist + 'include/jslibs/flowplayer/flowplayer-3.2.13.min.js' // @TODO: should be moved away (embed-bundle) ]; - return utils.buildJsGroup(commonGroup, 'common', 'common/js'); + return utils.buildJsGroup(commonGroup, 'common', 'common/js', debugMode); }); gulp.task('watch-common-js', function() { + debugMode = true; return gulp.watch(config.paths.src + 'common/**/*.js', ['build-common-js']); }); gulp.task('watch-common-css', function() { + debugMode = true; gulp.watch(config.paths.src + 'common/**/*.scss', ['build-common-css']); }); gulp.task('build-common', ['copy-common-images', 'build-common-css'], function(){ + debugMode = false; return gulp.start('build-common-js'); }); \ No newline at end of file diff --git a/resources/gulp/components/lightbox.js b/resources/gulp/components/lightbox.js index 8bb70699f1..f816827d45 100644 --- a/resources/gulp/components/lightbox.js +++ b/resources/gulp/components/lightbox.js @@ -1,6 +1,7 @@ var gulp = require('gulp'); var config = require('../config.js'); var utils = require('../utils.js'); +var debugMode = false; gulp.task('copy-lightbox-images', function(){ return gulp.src([config.paths.src + 'lightbox/images/**/*']) @@ -10,26 +11,26 @@ gulp.task('copy-lightbox-images', function(){ gulp.task('build-lightbox-mobile-css', function(){ return utils.buildCssGroup([ config.paths.src + 'lightbox/styles/main-mobile.scss' - ], 'lightbox-mobile', 'lightbox/css/'); + ], 'lightbox-mobile', 'lightbox/css/', debugMode); }); gulp.task('build-lightbox-mobile-js', function(){ return utils.buildJsGroup([ config.paths.src + 'lightbox/js/jquery.validator.mobile.js' - ], 'lightbox-mobile', 'lightbox/js'); + ], 'lightbox-mobile', 'lightbox/js', debugMode); }); gulp.task('build-lightbox-ie6-css', function(){ return utils.buildCssGroup([ config.paths.src + 'lightbox/styles/main-ie6.scss' - ], 'lightbox-ie6', 'lightbox/css/') + ], 'lightbox-ie6', 'lightbox/css/', debugMode) }); gulp.task('build-lightbox-css', ['build-lightbox-mobile-css', 'build-lightbox-ie6-css'], function(){ return utils.buildCssGroup([ config.paths.src + 'lightbox/styles/main.scss' - ], 'lightbox', 'lightbox/css/') + ], 'lightbox', 'lightbox/css/', debugMode) }); gulp.task('build-lightbox-js', ['build-lightbox-mobile-js'], function(){ @@ -40,18 +41,21 @@ gulp.task('build-lightbox-js', ['build-lightbox-mobile-js'], function(){ var lightboxIE6Group = [ config.paths.src + 'lightbox/js/jquery.lightbox.ie6.js' ]; - utils.buildJsGroup(lightboxIE6Group, 'lightboxIe6', 'lightbox/js'); - return utils.buildJsGroup(lightboxGroup, 'lightbox', 'lightbox/js'); + utils.buildJsGroup(lightboxIE6Group, 'lightboxIe6', 'lightbox/js', debugMode); + return utils.buildJsGroup(lightboxGroup, 'lightbox', 'lightbox/js', debugMode); }); gulp.task('watch-lightbox-js', function() { + debugMode = true; return gulp.watch(config.paths.src + 'lightbox/**/*.js', ['build-lightbox-js']); }); gulp.task('watch-lightbox-css', function() { + debugMode = true; gulp.watch(config.paths.src + 'lightbox/**/*.scss', ['build-lightbox-css']); }); gulp.task('build-lightbox', ['copy-lightbox-images', 'build-lightbox-css'], function(){ + debugMode = false; return gulp.start('build-lightbox-js'); }); \ No newline at end of file diff --git a/resources/gulp/components/oauth.js b/resources/gulp/components/oauth.js index e819a259f7..f337293887 100644 --- a/resources/gulp/components/oauth.js +++ b/resources/gulp/components/oauth.js @@ -3,9 +3,10 @@ var config = require('../config.js'); var utils = require('../utils.js'); gulp.task('watch-oauth-css', function() { + debugMode = true; gulp.watch(config.paths.src + 'oauth/**/*.scss', ['build-oauth']); }); gulp.task('build-oauth', function () { - return utils.buildCssGroup([config.paths.src + 'oauth/main.scss'], 'oauth', 'oauth/css/'); + return utils.buildCssGroup([config.paths.src + 'oauth/main.scss'], 'oauth', 'oauth/css/', debugMode); }); \ No newline at end of file diff --git a/resources/gulp/components/prod.js b/resources/gulp/components/prod.js index 1b34aaaec3..1678bad227 100644 --- a/resources/gulp/components/prod.js +++ b/resources/gulp/components/prod.js @@ -1,6 +1,7 @@ var gulp = require('gulp'); var config = require('../config.js'); var utils = require('../utils.js'); +var debugMode = false; // prod submodule @@ -20,7 +21,7 @@ gulp.task('build-permaview', function(){ config.paths.vendors + 'swfobject/swfobject/swfobject.js', // @TODO: should be moved away (embed-bundle) config.paths.dist + 'include/jslibs/flowplayer/flowplayer-3.2.13.min.js' // @TODO: should be moved away (embed-bundle) ]; - return utils.buildJsGroup(permaviewGroup, 'permaview', 'permaview/js'); + return utils.buildJsGroup(permaviewGroup, 'permaview', 'permaview/js', debugMode); }); gulp.task('copy-prod-skin-black-images', function(){ @@ -45,19 +46,19 @@ gulp.task('copy-prod-images', function(){ gulp.task('build-prod-skin-black', ['copy-prod-skin-black-images'], function(){ return utils.buildCssGroup([ config.paths.src + 'prod/skins/000000/skin-000000.scss' - ], 'skin-000000', 'prod/skins/000000/'); + ], 'skin-000000', 'prod/skins/000000/', debugMode); }); gulp.task('build-prod-skin-grey', ['copy-prod-skin-grey-images'], function(){ return utils.buildCssGroup([ config.paths.src + 'prod/skins/959595/skin-959595.scss' - ], 'skin-959595', 'prod/skins/959595/'); + ], 'skin-959595', 'prod/skins/959595/', debugMode); }); gulp.task('build-prod-css', ['build-prod-skin-black', 'build-prod-skin-grey'], function(){ return utils.buildCssGroup([ config.paths.src + 'prod/styles/main.scss' - ], 'prod', 'prod/css/'); + ], 'prod', 'prod/css/', debugMode); }); gulp.task('build-prod-js', function(){ var prodGroup = [ @@ -91,16 +92,19 @@ gulp.task('build-prod-js', function(){ config.paths.vendors + 'jquery-treeview/jquery.treeview.async.js', config.paths.vendors + 'fancytree/dist/jquery.fancytree-all.min.js' ]; - return utils.buildJsGroup(prodGroup, 'prod', 'prod/js'); + return utils.buildJsGroup(prodGroup, 'prod', 'prod/js', debugMode); }); gulp.task('watch-prod-js', function() { + debugMode = true; return gulp.watch(config.paths.src + 'prod/**/*.js', ['build-prod-js']); }); gulp.task('watch-prod-css', function() { + debugMode = true; return gulp.watch(config.paths.src + 'prod/**/*.scss', ['build-prod-css']); }); gulp.task('build-prod', ['copy-prod-images', 'build-prod-css'], function(){ + debugMode = false; return gulp.start('build-prod-js'); }); \ No newline at end of file diff --git a/resources/gulp/components/report.js b/resources/gulp/components/report.js index f0e41eddad..12fbea870a 100644 --- a/resources/gulp/components/report.js +++ b/resources/gulp/components/report.js @@ -1,6 +1,7 @@ var gulp = require('gulp'); var config = require('../config.js'); var utils = require('../utils.js'); +var debugMode = false; gulp.task('copy-report-images', function(){ return gulp.src([config.paths.src + 'report/images/**/*']) @@ -10,13 +11,13 @@ gulp.task('copy-report-images', function(){ gulp.task('build-report-print-css', function(){ return utils.buildCssGroup([ config.paths.src + 'report/styles/main-print.scss' - ], 'print', 'report/css/'); + ], 'print', 'report/css/', debugMode); }); gulp.task('build-report-css', ['build-report-print-css'], function(){ return utils.buildCssGroup([ config.paths.src + 'report/styles/main.scss' - ], 'report', 'report/css/'); + ], 'report', 'report/css/', debugMode); }); gulp.task('build-report-js', function(){ @@ -27,14 +28,16 @@ gulp.task('build-report-js', function(){ config.paths.src + 'report/js/jquery.gvChart-0.1.js', config.paths.src + 'report/js/report.js' ]; - return utils.buildJsGroup(reportGroup, 'report', 'report/js'); + return utils.buildJsGroup(reportGroup, 'report', 'report/js', debugMode); }); gulp.task('watch-report-js', function() { + debugMode = true; return gulp.watch(config.paths.src + 'report/**/*.js', ['build-report-js']); }); gulp.task('watch-report-css', function() { + debugMode = true; gulp.watch(config.paths.src + 'report/**/*.scss', ['build-report-css']); }); diff --git a/resources/gulp/components/setup.js b/resources/gulp/components/setup.js index a393d02bbe..c93ee2057d 100644 --- a/resources/gulp/components/setup.js +++ b/resources/gulp/components/setup.js @@ -1,6 +1,7 @@ var gulp = require('gulp'); var config = require('../config.js'); var utils = require('../utils.js'); +var debugMode = false; gulp.task('copy-setup-images', function(){ return gulp.src([config.paths.src + 'setup/images/**/*']) @@ -9,7 +10,7 @@ gulp.task('copy-setup-images', function(){ gulp.task('build-setup-css', function(){ utils.buildCssGroup([ config.paths.src + 'setup/styles/main.scss' - ], 'setup', 'setup/css/'); + ], 'setup', 'setup/css/', debugMode); }); gulp.task('build-setup-js', function(){ @@ -19,17 +20,20 @@ gulp.task('build-setup-js', function(){ config.paths.src + 'vendors/jquery-validate.password/js/jquery.validate.password.js', config.paths.src + 'setup/js/path_files_tests.jquery.js' ]; - return utils.buildJsGroup(setupGroup, 'setup', 'setup/js'); + return utils.buildJsGroup(setupGroup, 'setup', 'setup/js', debugMode); }); gulp.task('watch-setup-js', function() { + debugMode = true; return gulp.watch(config.paths.src + 'setup/**/*.js', ['build-setup-js']); }); gulp.task('watch-setup-css', function() { + debugMode = true; gulp.watch(config.paths.src + 'setup/**/*.scss', ['build-setup-css']); }); gulp.task('build-setup', ['copy-setup-images', 'build-setup-css'], function(){ + debugMode = false; return gulp.start('build-setup-js'); }); \ No newline at end of file diff --git a/resources/gulp/components/thesaurus.js b/resources/gulp/components/thesaurus.js index 73d1c02350..3f2487f360 100644 --- a/resources/gulp/components/thesaurus.js +++ b/resources/gulp/components/thesaurus.js @@ -1,6 +1,7 @@ var gulp = require('gulp'); var config = require('../config.js'); var utils = require('../utils.js'); +var debugMode = false; gulp.task('copy-thesaurus-images', function(){ return gulp.src([config.paths.src + 'thesaurus/images/**/*']) @@ -9,7 +10,7 @@ gulp.task('copy-thesaurus-images', function(){ gulp.task('build-thesaurus-css', function(){ return utils.buildCssGroup([ config.paths.src + 'thesaurus/styles/main.scss' - ], 'thesaurus', 'thesaurus/css/'); + ], 'thesaurus', 'thesaurus/css/', debugMode); }); gulp.task('build-thesaurus-js', function(){ @@ -20,14 +21,16 @@ gulp.task('build-thesaurus-js', function(){ config.paths.src + 'thesaurus/js/thesaurus.js', config.paths.src + 'thesaurus/js/sprintf.js' ]; - return utils.buildJsGroup(thesaurusGroup, 'thesaurus', 'thesaurus/js'); + return utils.buildJsGroup(thesaurusGroup, 'thesaurus', 'thesaurus/js', debugMode); }); gulp.task('watch-thesaurus-js', function() { + debugMode = true; return gulp.watch(config.paths.src + 'thesaurus/**/*.js', ['build-thesaurus-js']); }); gulp.task('watch-thesaurus-css', function() { + debugMode = true; gulp.watch(config.paths.src + 'thesaurus/**/*.scss', ['build-thesaurus-css']); }); diff --git a/resources/gulp/utils.js b/resources/gulp/utils.js index ad90a5baa5..ff68f1a347 100644 --- a/resources/gulp/utils.js +++ b/resources/gulp/utils.js @@ -1,5 +1,5 @@ var gulp = require('gulp'); -var util = require('gulp-util'); +var gutil = require('gulp-util'); var rename = require('gulp-rename'); var concat = require('gulp-concat'); var uglify = require('gulp-uglify'); @@ -11,13 +11,23 @@ var autoprefixer = require('gulp-autoprefixer'); var fs = require('fs'); -exports.buildJsGroup = function(srcGroup, name, dest){ +exports.buildJsGroup = function(srcGroup, name, dest, debugMode){ if( dest === undefined ) { dest = name; } // ensure all required files exists: srcGroup.forEach(fs.statSync); //will trow an error if file not found // console.log('building group:', name, ' > ', config.paths.build + dest) + + + if( debugMode === true ) { + gutil.log(gutil.colors.red('[DEBUG MODE]'), ' "' + name + '" minified version has not been generated'); + return gulp.src(srcGroup) + .pipe(concat(name + '.js', {newLine: ';'})) + .pipe(gulp.dest( config.paths.build + dest)) + .pipe(gulp.dest( config.paths.build + dest)) + } + return gulp.src(srcGroup) .pipe(concat(name + '.js', {newLine: ';'})) .pipe(gulp.dest( config.paths.build + dest)) @@ -26,13 +36,24 @@ exports.buildJsGroup = function(srcGroup, name, dest){ .pipe(gulp.dest( config.paths.build + dest)) }; -exports.buildCssGroup = function(srcGroup, name, dest){ +exports.buildCssGroup = function(srcGroup, name, dest, debugMode){ if( dest === undefined ) { dest = name; } // ensure all required files exists: srcGroup.forEach(fs.statSync); //will trow an error if file not found // console.log('building group:', name, ' > ', config.paths.build + dest) + + + if( debugMode === true ) { + gutil.log(gutil.colors.red('[DEBUG MODE]'), ' "' + name + '" minified version has not been generated'); + return gulp.src(srcGroup) + .pipe(sass().on('error', sass.logError)) + .pipe(autoprefixer()) + .pipe(rename(name + '.css')) + .pipe(gulp.dest(config.paths.build + dest)) + } + return gulp.src(srcGroup) .pipe(sass().on('error', sass.logError)) .pipe(autoprefixer()) diff --git a/resources/gulp/watch.js b/resources/gulp/watch.js index d3e3d89da6..576d25270e 100644 --- a/resources/gulp/watch.js +++ b/resources/gulp/watch.js @@ -48,4 +48,5 @@ gulp.task('sync', ['watch'], function(){ proxy: "phraseanet-php55-nginx" }); gulp.watch(config.paths.build + '**/*.css').on('change', browserSync.reload); + gulp.watch(config.paths.build + '**/*.js').on('change', browserSync.reload); });