Reputation: 4407
I have a gulpfile watching for changes in a following folder:
SCSSSource = '../framework/**/*.scss';
This will watch for changes in following example files:
'../framework/styling.scss'
// root folder'../framework/subfolder1/styling.scss'
'../framework/subfolder2/styling.scss'
I would like to exclude all files from a root folder (1.), and leave only a subfolders to be watched. How should i modify SCSSSource
String, to achieve that?
Full Code:
var gulp = require('gulp');
var watch = require('gulp-watch');
var concat = require('gulp-concat-util');
gulp.task('watch', function(){
// "./*" - all in current foler
// "./**" - all in current foler and subfolders
// SCSS FILE
var SCSSPath = '../framework/';
var SCSSName = '**/*.scss';
var SCSSSource = SCSSPath + SCSSName;
function concatSCSS(){
// concatenate files
gulp.src(SCSSSource)
.pipe(concat('_cssfw.scss', {
process: function(src){
src = "\n\n\n\/\/ ----------------------------------------------------------------------\n\n"
+ src;
return src;
}
}))
.pipe(concat.header('\/\/SCSS Framework\n\n'))
.pipe(gulp.dest(SCSSPath + "./"));
}
watch('../framework/**/*.scss', function (info) {
concatSCSS();
console.log(info.event + " scss: " + info.history[0].replace(/^.*[\\\/]/, ''))
});
concatSCSS();
});
Upvotes: 0
Views: 571
Reputation: 36
I Think you could use the glob pattern to exclude the .scss
files in the root folder, like this:
var SCSSSource = SCSSPath + SCSSName;
var exclude = "!../framework/*.scss"
function concatSCSS(){
// concatenate files
gulp.src([SCSSSource, exclude])
This way you only get the .scss files from the subdirectories
Upvotes: 2