gulp.task('districtSass', function() {
var districtSchoolSass=null;
if(config.districts.length) {
config.districts.forEach(function(school) {
districtSchoolSass = 'src/sass/districts/'+school+'.scss';
if(!fs.existsSync(districtSchoolSass)) {
fs.writeFileSync(districtSchoolSass, '@import "all";')
}
return gulp.src([districtSchoolSass,'src/sass/districts/_all.scss'])
// .pipe(changed(themepath+'/districts/'+school+'/css', {extension: '.css'}))
.pipe(sass({ style : config.sass_style}))
.on("error", handleError)
.pipe(autoprefixer({
browsers: ['> 1%', 'last 4 versions', 'Firefox ESR', 'Opera 12.1'],
cascade: false
}))
.pipe(gulp.dest('./dist/districts/'+school+'/css'))
.pipe(gulp.dest(themepath+'/districts/'+school+'/css'))
.pipe(browserSync.stream());
});
}
});
I have this sort of setup
/src/sass/districts/_all.scss
/src/sass/districts/school1.scss
//more schools
I’m trying to make it so if I save a school file, it only recompiles that one Sass file, but if I save _all, then every file gets recompiled. Right now every file gets recompiled no matter what, but if I uncomment that pipe(changed()) line, then it works EXCEPT for when I need to save _all; THEN it doesn’t compile anything / push to the dest()'s. Any ideas? I found merge-stream npm but it wasn’t working for me so I abandoned it.