The source code is used for 2 projects, Each project has some common code. I want to conditionally ignore a module/folder/directory via gulp task.
When I do following it works perfectly
return gulp.src(
config.appMarkupFiles
'!app/settings', '!app/settings/**'
)
However, I want to do it conditionally. I have also tried the following code using gulp-filter which does not work for me.
var isQA = $.yargs.argv.stage === 'qa';
var filterSettings = $.filter(['!app/settings{, /**}'])
return gulp.src(
config.appMarkupFiles
)
.pipe(($.if(isQA,$.filter(filterSettings)))
Your gulpfile is just JavaScript so you can use the ternary operator to conditionally exclude files in
gulp.src()
:Using
gulp-filter
works, but you had two mistakes in your code:!app/settings{, /**}
and$.filter
twice.Here's a working solution using
gulp-filter
: