Skip to content

Commit

Permalink
Merge pull request #1342 from austinpray/fixWatch
Browse files Browse the repository at this point in the history
fix less breaking during watch on error
  • Loading branch information
retlehs committed Feb 24, 2015
2 parents bcb782d + ad4523f commit 1d4554f
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ var enabled = {
// Enable static asset revisioning when `--production`
rev: argv.production,
// Disable source maps when `--production`
maps: !argv.production
maps: !argv.production,
// Fail styles task on error when `--production`
failStyleTask: argv.production
};

// Path to the compiled assets manifest in the dist directory
Expand All @@ -60,21 +62,21 @@ var revManifest = path.dist + 'assets.json';
// ```
var cssTasks = function(filename) {
return lazypipe()
.pipe($.plumber)
.pipe(function() {
return $.if(!enabled.failStyleTask, $.plumber());
})
.pipe(function() {
return $.if(enabled.maps, $.sourcemaps.init());
})
.pipe(function() {
return $.if('*.less', $.less().on('error', function(err) {
console.warn(err.message);
}));
return $.if('*.less', $.less());
})
.pipe(function() {
return $.if('*.scss', $.sass({
outputStyle: 'nested', // libsass doesn't support expanded yet
precision: 10,
includePaths: ['.'],
onError: console.error.bind(console, 'Sass error:')
errLogToConsole: !enabled.failStyleTask
}));
})
.pipe($.concat, filename)
Expand Down Expand Up @@ -137,11 +139,20 @@ var writeToManifest = function(directory) {

// ### Styles
// `gulp styles` - Compiles, combines, and optimizes Bower CSS and project CSS.
// By default this task will only log a warning if a precompiler error is
// raised. If the `--production` flag is set: this task will fail outright.
gulp.task('styles', ['wiredep'], function() {
var merged = merge();
manifest.forEachDependency('css', function(dep) {
var cssTasksInstance = cssTasks(dep.name);
if (!enabled.failStyleTask) {
cssTasksInstance.on('error', function(err) {
console.error(err.message);
this.emit('end');
});
}
merged.add(gulp.src(dep.globs, {base: 'styles'})
.pipe(cssTasks(dep.name)));
.pipe(cssTasksInstance));
});
return merged
.pipe(writeToManifest('styles'));
Expand Down

0 comments on commit 1d4554f

Please sign in to comment.