Closed albertogiovanelli91 closed 2 years ago
You should check the 'watch' from gulp api:
I had a file called style.scss that calls another 3 includes files in the same folder. I watch for changes in all files, but it compiles only the style.scss file. I could archive this by using the API funcion watch from gulp like this:
const gulp = require('gulp');
const sass = require('gulp-sass');
function scss(){
// here you put all the files that needs to be compiled
return gulp.src('resources/style.scss')
.pipe(sass({outputStyle: 'compressed',includePaths: ['./resources']}).on('error', sass.logError))
.pipe(gulp.dest(dest));
}
gulp.task('watch', () => {
// here you put all files that needs to be watched
gulp.watch('resources/*.scss', { events: 'all' }, function(cb) {
scss();
cb();
});
});
Can I watch for changes file imported inside my main.sass file?
How can I pass node-sass options like --watch and --recursive inside the task. I tried the following but seems to not work:
gulp.task('sass', function () { return gulp.src(app+'/sass/main.sass') .pipe(sass({watch: true, recursive: true})) .pipe(gulp.dest(public+'/css')); });
Thanks