Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gulp condition inside pipe

How can I do a condition inside Gulp pipe to output to a different destination.

g.task('sass', function() {   return g.src(sources.sass).pipe(changed(output.css)).pipe(sass({     style: 'compressed',     sourcemap: true   })).pipe(function() {     if (..) {       g.dest(output.css);     } else {       g.dest(output.css2);     }   }).pipe(notify('scss converted to css and compressed <%=f ile.relative %>')); }); 
like image 515
max li Avatar asked Nov 28 '14 04:11

max li


1 Answers

Use the gulp-if plugin:

var gulpif = require('gulp-if');  g.task('sass', function() {     return g.src(sources.sass)         .pipe(changed(output.css))         .pipe(sass({style:'compressed', sourcemap:true}))          // Conditional output         .pipe(gulpif(condition1, g.dest(output.css)))         .pipe(gulpif(condition2, g.dest(output.css2)))          .pipe(notify('scss converted to css and compressed <%= file.relative %>')); }); 
like image 111
Daniel Naab Avatar answered Nov 09 '22 11:11

Daniel Naab