Skip to content

Commit

Permalink
Dashboard: fail build when webpack has errors
Browse files Browse the repository at this point in the history
Signed-off-by: Lucia Jelinkova <ljelinko@redhat.com>
  • Loading branch information
ljelinkova committed Apr 26, 2019
1 parent de72c6a commit d40658f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
8 changes: 6 additions & 2 deletions dashboard/gulp/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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);
20 changes: 13 additions & 7 deletions dashboard/gulp/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,26 @@ 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 && stats.hasErrors()) {
$.util.log("Webpack task failed with errors");
process.exit(1);
}

if (watch) {
watch = false;
callback();
if (!callbackCalled) {
callbackCalled = true;
callback();
}
}
};

Expand All @@ -111,7 +117,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);
});

Expand Down
7 changes: 4 additions & 3 deletions dashboard/gulp/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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();
});


Expand Down

0 comments on commit d40658f

Please sign in to comment.