I use Gulp 4 with gulp-sass. What I try to do is the following.
- The code I provide here is just a fragment of the whole code, to show the important parts.
- The
watchshould like it does, watch all.scssfiles. - In
style(), only the current file is going to be processed. - If I save
custom/components/header/header.scss, then onlycustom/components/header/header.scssshould be processed, not all files. - The saved file should then have a filename like
assets/css/dist/header/header.css - Both
srcanddestis unknown in this case because I don't have a single file to grab on to. - I see now that I also need to remove
custom/componentsfrom thedest, 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.