Dashboard: fail build when webpack has errors
Signed-off-by: Lucia Jelinkova <ljelinko@redhat.com>7.20.x
parent
2cc7da549e
commit
51bb0bb13f
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue