Not exactly what you want but I'm using this to avoid partials/includes/children from being parsed separately.
var gulp = require('gulp');
var filter = require('gulp-filter');
var sass = require('gulp-sass');
gulp.task('styles', function () {
return gulp.src('app/css/**/*.scss')
.pipe(filter(noPartials))//avoid compiling SCSS partials
.pipe(sass())
.pipe(gulp.dest('dist'));
});
You should watch all the files, including partials, so that the task is triggered when they change too.
gulp.task('watch', function() {
gulp.watch('app/css/**/*.scss', ['styles']); //watch ALL the SCSS files
});
Partials are recognized by the _
at the beginning of the filename or containing folder's name.
var noPartials = function (file) {
var path = require('path');
var dirSeparator = path.sep.replace('\\', '\\\\');
var relativePath = path.relative(process.cwd(), file.path);
return !new RegExp('(^|'+dirSeparator+')_').test(relativePath);
};
The only downside to this is that all the non-partials files will be rendered when any SCSS file changes.
As a side note: I made exactly what you asked, but for Jade (html templating language), using a plugin that figures out the dependency tree/graph. So it is possible, if someone find a way to build that tree for SASS files