diff --git a/tasks/browsersync.js b/tasks/browsersync.js index 7e30b31..6798af4 100644 --- a/tasks/browsersync.js +++ b/tasks/browsersync.js @@ -4,6 +4,11 @@ function browsersync(gulp, $, config, css, js) { open: false }); + // set a config param to signal browserSync is active; + // styles.js will suppress errors for this env to avoid + // the watch process exiting on errors + config.livereload = true; + gulp.watch(config.styles.watch, { usePolling: true }, css); gulp.watch(config.scripts.watch, { usePolling: true }, js); } diff --git a/tasks/styles.js b/tasks/styles.js index a8562f5..e13f0fd 100644 --- a/tasks/styles.js +++ b/tasks/styles.js @@ -1,3 +1,5 @@ +const PluginError = require('plugin-error'); + function styles(gulp, $, config) { // take the array and map over each script config object in it const tasks = config.styles.files.map((stylesheet) => { @@ -15,7 +17,12 @@ function styles(gulp, $, config) { pipeStdout: true, sassOutputStyle: 'nested', includePaths: config.styles.includePaths ? config.styles.includePaths : [config.npmdir] - }).on('error', $.sass.logError)) + }).on('error', function(error) { + const message = new PluginError('sass', error.messageFormatted).toString(); + process.stderr.write(`${message}\n`); + config.livereload ? $.through2.obj() : process.exitCode = 1; + done(); + })) .pipe($.postcss(config.styles.postCssPlugins(config, stylesheet))) .pipe($.concat(stylesheet.name)) .pipe($.cleanCss({