I use Gulp 4 with gulp-sass. What I try to do is the following.
watch
should like it does, watch all .scss
files.style()
, only the current file is going to be processed.custom/components/header/header.scss
, then only custom/components/header/header.scss
should be processed, not all files.assets/css/dist/header/header.css
src
and dest
is unknown in this case because I don't have a single file to grab on to.custom/components
from the dest
, but the important thing is that I can get the current file to start working with that.gulp.watch('custom/components/**/*.scss', style);
function style() {
return gulp
.src()
.pipe(sass())
.on('error', sass.logError)
.pipe(gulp.dest('assets/css/dist'));
}
I just figure it out. It's possible to do it like this.
let watcher = gulp.watch(css.watch);
watcher.on('change', function(path) {
console.log(path);
style();
}