Skip to content

Commit

Permalink
#69 Better output for webpack errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Quicksaver committed Mar 27, 2018
1 parent 005dd48 commit 67e58c5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 222 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
"postcss-cli": "^4.1.1",
"punycode": "^2.1.0",
"react": "^16.2.0",
"react-dev-utils": "^5.0.0",
"react-dom": "^16.2.0",
"react-html-parser": "^2.0.2",
"ritmo": "^0.5.0",
Expand Down
12 changes: 6 additions & 6 deletions scripts/libs/WebpackLoggerPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const Spinner = require('./Spinner');

// Borrowed heavily from https://github.com/michaelgilley/webpack-logger-plugin/

const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages')
const ProgressPlugin = require('webpack').ProgressPlugin;

const internal = {
Expand Down Expand Up @@ -127,14 +126,15 @@ module.exports = class WebpackLoggerPlugin {

// Webpack has finished bundling and processing the files.
compiler.plugin('done', (stats) => {
let messages = formatWebpackMessages(stats.toJson());

if (!messages.errors.length && !messages.warnings.length) {
if (!stats.hasErrors() && !stats.hasWarnings()) {
internal.success(this);
return;
}

let toShow = (messages.errors.length) ? messages.errors : messages.warnings;
for(let err of toShow) {
// We don't need to show 50 times the same error if the script just happens
// to run on 50 different pages.
let messages = new Set(stats.toJson()[stats.hasErrors() ? 'errors' : 'warnings']);
for(let err of messages) {
internal.error(this, err);
}
});
Expand Down
Loading

0 comments on commit 67e58c5

Please sign in to comment.