Dashboard: fail build when webpack has errors

Signed-off-by: Lucia Jelinkova <ljelinko@redhat.com>
7.20.x
Lucia Jelinkova 2019-03-15 14:24:02 +01:00 committed by Oleksii Orel
parent 2cc7da549e
commit 51bb0bb13f
3 changed files with 22 additions and 13 deletions

View File

@ -18,7 +18,7 @@ var conf = require('./conf');
var $ = require('gulp-load-plugins')();
gulp.task('inject', ['outputcolors', 'proxySettings', 'scripts', 'styles'], function () {
function inject() {
var injectStyles = gulp.src([
path.join(conf.paths.tmp, '/serve/app/**/*.css'),
path.join('!' + conf.paths.tmp, '/serve/app/vendor.css')
@ -37,4 +37,8 @@ gulp.task('inject', ['outputcolors', 'proxySettings', 'scripts', 'styles'], func
.pipe($.inject(injectStyles, injectOptions))
.pipe($.inject(injectScripts, injectOptions))
.pipe(gulp.dest(path.join(conf.paths.tmp, '/serve')));
});
}
gulp.task('inject', ['outputcolors', 'proxySettings', 'scripts', 'styles'], inject);
gulp.task('inject:watch', ['outputcolors', 'proxySettings', 'scripts:watch', 'styles'], inject);

View File

@ -80,20 +80,24 @@ function webpackWrapper(watch, test, callback) {
webpackOptions.devtool = 'inline-source-map';
}
var callbackCalled = false;
var webpackChangeHandler = function (err, stats) {
if (err) {
conf.errorHandler('Webpack')(err);
}
$.util.log(stats.toString({
colors: $.util.colors.supportsColor,
chunks: false,
hash: false,
version: false
}));
browserSync.reload();
if (watch) {
watch = false;
callback();
if (!watch && stats.hasErrors()) {
$.util.log($.util.colors.red('[Webpack task failed with errors]'));
process.exit(1);
}
if (watch && !callbackCalled) {
callbackCalled = true;
callback();
}
};
@ -111,7 +115,7 @@ gulp.task('scripts', ['colors', 'proxySettings'], function () {
return webpackWrapper(false, false);
});
gulp.task('scripts:watch', ['scripts'], function (callback) {
gulp.task('scripts:watch', ['colors', 'proxySettings'], function (callback) {
return webpackWrapper(true, false, callback);
});

View File

@ -22,9 +22,9 @@ function isOnlyChange(event) {
return event.type === 'changed';
}
gulp.task('watch', ['scripts:watch', 'inject'], function () {
gulp.task('watch', ['scripts:watch', 'inject:watch'], function () {
gulp.watch([path.join(conf.paths.src, '/*.html')], ['inject']);
gulp.watch([path.join(conf.paths.src, '/*.html')], ['inject:watch']);
gulp.watch([
path.join(conf.paths.src, '/app/**/*.css'),
@ -35,8 +35,9 @@ gulp.task('watch', ['scripts:watch', 'inject'], function () {
if(isOnlyChange(event)) {
gulp.start('styles');
} else {
gulp.start('inject');
gulp.start('inject:watch');
}
browserSync.reload();
});