I was wondering if there is a way to pass the parameters from gulp-watch to gulp-sass. In order to customise the gulp-sass task.
I have two tasks when I could have just one if I could pass the parameter based on the file that is being watched by gulp-watch task. Let's say if the file framework.scss being change I could simply pass the relevant src parameter via watch to sass task changing the gulp.src(src) value. Because that is the only difference in both tasks.
Basically I am trying to make the gulp-sass task dynamical. As then I could simply put if statement into gulp-watch task, which would track the file being changed and pass the parameter to gulp-sass depending on the outcome of the if statement.
gulp.task('sass:framework', function() {
gulp.src(app.src.scss + '/framework.scss')
.pipe(sourcemaps.init())
.pipe(sass({
includePaths: require('node-bourbon').with(app.fwrk.scss, app.src.scss)
}).on('error', sass.logError))
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write())
.pipe(gulp.dest(app.dest.css))
});
gulp.task('sass:app', function() {
gulp.src(app.src.scss + '/app.scss')
.pipe(sourcemaps.init())
.pipe(sass({
includePaths: require('node-bourbon').with(app.fwrk.scss, app.src.scss)
}).on('error', sass.logError))
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write())
.pipe(gulp.dest(app.dest.css))
});
gulp.task('watch', function() {
livereload.listen(35729, function(err) {
if (err) {
return console.log(err);
}
});
gulp.watch(app.src.scss + '/_settings.scss', ['sass:framework', 'sass:app'])
gulp.watch([app.src.scss + '/app.scss', app.src.scss + '/app/*.scss'], ['sass:app'])
gulp.watch(app.src.scss + '/framework.scss', ['sass:framework'])
gulp.watch([basepath + '/**/**/**/*.php', app.dest.css + '/**/**/*.css', app.dest.js+ '/**/*.js']).on('change', livereload.changed);
});
Thanks for any help in advance.