Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dashboard: fail build when webpack has errors #12911

Merged
merged 1 commit into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 12 additions & 8 deletions dashboard/gulp/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};

Expand All @@ -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);
});

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