When using Gulp and Gulp-sass, with the use of 'gulp.watch', how can I retrieve the directory name of the modified item on the watchlist in order to compile the sass to css?
Currently, the setup only compiles the sass files from theme 1. If there are changes in the sass files of theme 2 or 3, the css of theme 1 gets updated. The goal is to create a conditional process so that each theme's css gets compiled based on their own changes.
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('sass', function () {
return gulp.src('./wp-content/themes/1/assets/sass/**/*.scss')
.pipe(sass.sync().on('error', sass.logError))
.pipe(gulp.dest('./wp-content/themes/1/'));
});
gulp.task('sass:watch', function () {
gulp.watch('./wp-content/themes/1/assets/sass/**/*.scss', ['sass']);
gulp.watch('./wp-content/themes/2/assets/sass/**/*.scss', ['sass']);
gulp.watch('./wp-content/themes/3/assets/sass/**/*.scss', ['sass']);
});