@@ -25,6 +25,7 @@ var run = require('run-sequence');
2525
2626//gulp plugins
2727var gutil = require ( 'gulp-util' ) ;
28+ var gif = require ( 'gulp-if' ) ;
2829var sass = require ( 'gulp-sass' ) ;
2930var rename = require ( 'gulp-rename' ) ;
3031var vulcanize = require ( 'gulp-vulcanize' ) ;
@@ -60,11 +61,18 @@ var PATCH_LIST = [
6061 'bower_components/moment/min/moment.min.js'
6162] ;
6263
64+ var IS_DEBUG = ! ! gutil . env . debug ;
65+ console . log ( IS_DEBUG ) ;
66+
67+ function dbg ( t ) {
68+ return gif ( IS_DEBUG , debug ( { title :t } ) ) ;
69+ }
70+
6371/** BUILD **/
6472
6573gulp . task ( 'patch-lib' , function ( ) {
6674 gulp . src ( PATCH_LIST , { base : j ( __dirname , 'bower_components' ) } )
67- . pipe ( debug ( ) )
75+ . pipe ( dbg ( 'patch-lib' ) )
6876 . pipe ( wrap ( "(function(define, require) { {{{contents}}} })();" , { } , { engine :"hogan" } ) . on ( 'error' , console . error ) )
6977 . pipe ( gulp . dest ( j ( __dirname , 'bower_components' ) ) ) ;
7078} ) ;
@@ -80,7 +88,7 @@ gulp.task('clean:dist', function() {
8088gulp . task ( 'copy' , function ( ) {
8189 return gulp . src ( [ j ( SRC , '**/*.+(html|js|woff)' ) , j ( '!' , SRC , '**/example.html' ) ] )
8290 . pipe ( cache ( 'copy' ) )
83- . pipe ( debug ( ) )
91+ . pipe ( dbg ( 'copy' ) )
8492 . pipe ( gulp . dest ( BUILD ) ) ;
8593} ) ;
8694
@@ -90,21 +98,25 @@ gulp.task('sass', function() {
9098 . pipe ( cache ( 'scss' ) )
9199 . pipe ( sass ( { includePaths : [ './bower_components/bourbon/app/assets/stylesheets/' , './src/shared/sass/' ] } ) . on ( 'error' , sass . logError ) )
92100 . pipe ( postcss ( [ autoprefixer ( { browsers : [ 'last 2 versions' ] } ) ] ) )
101+ . pipe ( dbg ( 'sass' ) )
93102 . pipe ( gulp . dest ( BUILD ) )
94103 . pipe ( wrap ( function ( data ) {
95104 data . fname = path . basename ( data . file . relative , '.css' ) ;
96105 return wrapper ;
97106 } , { } , { engine :"hogan" } ) )
98107 . pipe ( rename ( { basename :"style" , extname : ".html" } ) )
108+ . pipe ( dbg ( 'sass-html' ) )
99109 . pipe ( gulp . dest ( BUILD ) ) ;
100110} ) ;
101111
102112gulp . task ( 'font' , function ( ) {
103113 return gulp . src ( SRC + 'shared/fonts/fonts.scss' )
104114 . pipe ( sass ( { includePaths : [ './bower_components/bourbon/app/assets/stylesheets/' , './src/shared/sass/' ] } ) . on ( 'error' , sass . logError ) )
115+ . pipe ( dbg ( 'font' ) )
105116 . pipe ( gulp . dest ( BUILD + 'shared/fonts/' ) )
106117 . pipe ( wrap ( "<style>{{{contents}}}</style>" , { } , { engine :"hogan" } ) . on ( 'error' , console . log ) )
107118 . pipe ( rename ( "fonts.html" ) . on ( 'error' , console . log ) )
119+ . pipe ( dbg ( 'font-output' ) )
108120 . pipe ( gulp . dest ( j ( BUILD , '/shared/fonts/' ) ) ) ;
109121} ) ;
110122
@@ -151,7 +163,7 @@ gulp.task('vulcanize', function() {
151163 inlineCss : true ,
152164 implicitStrip : false
153165 } , excludes , BUILD ) )
154- . pipe ( debug ( ) )
166+ . pipe ( dbg ( 'vulcanize-modules' ) )
155167 . pipe ( htmlmin ( ) )
156168 . pipe ( gulp . dest ( BUILD ) ) ;
157169
@@ -160,6 +172,7 @@ gulp.task('vulcanize', function() {
160172 inlineScripts : true ,
161173 inlineCss : true
162174 } ) )
175+ . pipe ( dbg ( 'vulcanize-lib' ) )
163176 . pipe ( gulp . dest ( BUILD ) ) ;
164177 return merge ( modules , lib ) ;
165178} ) ;
@@ -190,6 +203,7 @@ gulp.task('build:prod', ['patch-lib', 'build'], function() {
190203 } ) )
191204 . pipe ( inlinemin ( ) )
192205 . pipe ( header ( '<!--\n' + fs . readFileSync ( 'BANNER.txt' , 'utf8' ) + ' -->' ) )
206+ . pipe ( dbg ( 'vulcanize-modules' ) )
193207 . pipe ( gulp . dest ( DIST ) ) ;
194208
195209 var lib = gulp . src ( j ( BUILD , 'strand.html' ) )
@@ -206,6 +220,7 @@ gulp.task('build:prod', ['patch-lib', 'build'], function() {
206220 } ) )
207221 . pipe ( inlinemin ( ) )
208222 . pipe ( header ( '<!--\n' + fs . readFileSync ( 'BANNER.txt' , 'utf8' ) + ' -->' ) )
223+ . pipe ( dbg ( 'vulcanize-lib' ) )
209224 . pipe ( gulp . dest ( DIST ) ) ;
210225
211226 return merge ( modules , lib ) ;
@@ -227,17 +242,19 @@ gulp.task('copy:docs', function() {
227242 . pipe ( gulp . dest ( BUILD_DOCS ) ) ;
228243
229244 var bower_components = gulp . src ( [ 'bower_components/webcomponentsjs/**/*' , 'bower_components/polymer/**/*' ] , { base :'bower_components' } )
230- . pipe ( debug ( ) )
245+ . pipe ( dbg ( 'copy-bower' ) )
231246 . pipe ( gulp . dest ( BUILD_DOCS + '/bower_components/' ) ) ;
232247
233248 var lib = gulp . src ( j ( BUILD , '**' ) )
249+ . pipe ( dbg ( 'copy-lib' ) )
234250 . pipe ( gulp . dest ( j ( BUILD_DOCS , '/bower_components/strand/dist' ) ) ) ;
235251
236252 return merge ( bower_components , merged_static , lib ) ;
237253} ) ;
238254
239255gulp . task ( 'sass:docs' , function ( ) {
240256 return gulp . src ( 'docs/**/*.scss' )
257+ . pipe ( dbg ( 'sass-docs' ) )
241258 . pipe ( sass ( { includePaths : [ './bower_components/bourbon/app/assets/stylesheets/' , './src/shared/sass/' ] } ) . on ( 'error' , sass . logError ) )
242259 . pipe ( postcss ( [ autoprefixer ( { browsers : [ 'last 2 versions' ] } ) ] ) )
243260 . pipe ( gulp . dest ( BUILD_DOCS ) ) ;
@@ -415,7 +432,7 @@ gulp.task('docs:templates', function() {
415432 . pipe ( cache ( 'docs_module' ) )
416433 . pipe ( injectBehaviorDocs ( behaviorsMap ) )
417434 . pipe ( injectModuleData ( pkg , moduleMap , articleList , articleMap ) )
418- // .pipe(debug( ))
435+ . pipe ( dbg ( 'docs-modules' ) )
419436 . pipe ( through . obj ( function ( file , enc , cb ) {
420437 var moduleDoc = JSON . parse ( file . contents ) ;
421438 var templatePath = path . join ( __dirname , 'docs/component_template.html' ) ;
@@ -439,6 +456,7 @@ gulp.task('docs:templates', function() {
439456 . pipe ( marked ( ) . on ( 'error' , console . log ) )
440457 . pipe ( injectArticleData ( pkg , moduleMap , articleList , articleMap ) )
441458 . pipe ( rename ( { prefix : 'article_' } ) )
459+ . pipe ( dbg ( 'docs-articles' ) )
442460 . pipe ( gulp . dest ( BUILD_DOCS ) ) ;
443461
444462 return merge ( indexStream , moduleStream , articleStream ) ;
@@ -447,6 +465,7 @@ gulp.task('docs:templates', function() {
447465gulp . task ( 'gh-pages' , function ( ) {
448466 var pkg = getPkgInfo ( ) ;
449467 return gulp . src ( BUILD_DOCS + '**/*' )
468+ . pipe ( dbg ( 'gh-pages' ) )
450469 . pipe ( ghPages ( {
451470 message : 'docs updates v' + pkg . version
452471 } ) ) ;
@@ -467,7 +486,7 @@ gulp.task('index', function() {
467486 var templateString = fs . readFileSync ( templatePath ) . toString ( 'utf8' ) ;
468487 var template = hogan . compile ( templateString ) ;
469488 var index = template . render ( moduleMap ) ;
470- fs . writeFileSync ( path . join ( BUILD , 'index.html' ) , index ) ;
489+ fs . writeFileSync ( j ( BUILD , 'index.html' ) , index ) ;
471490} ) ;
472491
473492gulp . task ( 'server' , function ( ) {
@@ -540,7 +559,7 @@ gulp.task('changelog', function() {
540559 }
541560 }
542561 } ) )
543- . pipe ( debug ( ) )
562+ . pipe ( dbg ( 'changelog' ) )
544563 . pipe ( gulp . dest ( '.' ) ) ;
545564} ) ;
546565
0 commit comments