Skip to content

Commit e5939eb

Browse files
Show error if CSS doesn't compile (#337)
Taken from the updates in the NHS prototype kit.
1 parent 2d0248d commit e5939eb

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

gulpfile.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const clean = require('gulp-clean');
88
const gulpSass = require('gulp-sass')
99
const dartSass = require('sass-embedded')
1010
const nodemon = require('gulp-nodemon');
11+
const PluginError = require('plugin-error')
1112

1213
// Local dependencies
1314
const config = require('./app/config');
@@ -23,15 +24,20 @@ function cleanPublic() {
2324
const sass = gulpSass(dartSass)
2425

2526
// Compile SASS to CSS
26-
function compileStyles() {
27+
function compileStyles(done) {
2728
return gulp
2829
.src(['app/assets/sass/**/*.scss'])
29-
.pipe(sass())
30+
.pipe(
31+
sass()
32+
.on('error', (error) => {
33+
done(
34+
new PluginError('compileCSS', error.messageFormatted, {
35+
showProperties: false
36+
})
37+
)
38+
})
39+
)
3040
.pipe(gulp.dest('public/css'))
31-
.on('error', (err) => {
32-
console.log(err);
33-
process.exit(1);
34-
});
3541
}
3642

3743
// Compile JavaScript (with ES6 support)

0 commit comments

Comments
 (0)