@@ -114,7 +114,13 @@ let styles = lazypipe()
114114 . pipe ( plugins . sass ) < % } % >
115115 . pipe ( plugins . autoprefixer , { browsers : [ 'last 1 version' ] } )
116116 . pipe ( plugins . sourcemaps . write , '.' )
117- . pipe ( gulp . dest , '.tmp/app' ) ;
117+ . pipe ( gulp . dest , '.tmp/app' ) ; < % if ( filters . babel || filters . coffee ) { % >
118+
119+ let transpile = lazypipe ( )
120+ . pipe ( plugins . sourcemaps . init ) < % if ( filters . babel ) { % >
121+ . pipe ( plugins . babel ) < % } else { % >
122+ . pipe ( plugins . coffee , { bare : true } ) < % } % >
123+ . pipe ( plugins . sourcemaps . write , '.' ) ; < % } % >
118124
119125/********************
120126 * Tasks
@@ -157,15 +163,13 @@ gulp.task('inject:sass', () => {
157163 . pipe ( gulp . dest ( 'client/app' ) ) ;
158164} ) ;
159165
160- gulp . task ( 'styles' , styles ) ; < % if ( filters . coffee ) { % >
166+ gulp . task ( 'styles' , styles ) ; < % if ( filters . babel || filters . coffee ) { % >
161167
162- gulp . task ( 'coffee' , ( ) =>
163- gulp . src ( paths . client . scripts )
164- . pipe ( lintClientScripts ( ) )
165- . pipe ( lintServerScripts ( ) )
166- . pipe ( plugins . coffee ( { bare : true } ) . on ( 'error' , plugins . util . log ) )
167- . pipe ( gulp . dest ( '.tmp/scripts' ) ) ;
168- ) ; < % } % >
168+ gulp . task ( 'transpile' , ( ) => {
169+ return gulp . src ( paths . client . scripts )
170+ . pipe ( transpile ( ) )
171+ . pipe ( gulp . dest ( '.tmp' ) ) ;
172+ } ) ; < % } % >
169173
170174gulp . task ( 'lint:scripts' , cb => runSequence ( [ 'lint:scripts:client' , 'lint:scripts:server' ] , cb ) ) ;
171175
@@ -202,9 +206,8 @@ gulp.task('watch', () => {
202206 . pipe ( plugins . livereload ( ) ) ;
203207
204208 plugins . watch ( paths . client . scripts )
205- . pipe ( plugins . plumber ( ) )
206- . pipe ( lintClientScripts ( ) ) < % if ( filters . coffee ) { % >
207- . pipe ( plugins . coffee ( { bare : true } ) . on ( 'error' , plugins . util . log ) )
209+ . pipe ( plugins . plumber ( ) ) < % if ( filters . babel || filters . coffee ) { % >
210+ . pipe ( transpile ( ) )
208211 . pipe ( gulp . dest ( '.tmp/scripts' ) ) < % } %>
209212 . pipe ( plugins . livereload ( ) ) ;
210213
0 commit comments