Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix less breaking during watch on error #1342

Merged
merged 1 commit into from
Feb 24, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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