I'm trying to compile all the .less
files to css, and leave .import.less
files unprocessed (similar to Meteor less package). My file structure is as follow:
assets/less/normalize.less
assets/less/main.less
assets/less/header.import.less
assets/less/footer.import.less
assets/less/...
My lessCompile
task works fine by itself (i.e. run it manually by gulp lessCompile
).
gulp.task('lessCompile', function() {
gulp.src(['assets/less/main.less', '!assets/less/*.import.less'])
.pipe(less())
.pipe(autoprefix('last 2 version'))
.pipe(minifyCSS({ advanced: true }))
.pipe(concat('style.min.css'))
.pipe(gulp.dest('public/stylesheets'));
});
Now I add a watch to all the .less
files to automate the compilation.
gulp.task('default', ['lessCompile'], function () {
gulp.watch('assets/less/*.less', ['lessCompile']);
});
Problem is after I edited assets/less/footer.import.less
, lessCompile
task re-ran itself and all the styles in footer.import.less
disappeared from the minified style.min.css
. The same disappearance goes for editing any other *.import.less
such as header.import.less
. Also, there are no errors during the re-compile process.