1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/webpack-dev-middleware/lib/reporter.js

33 lines
813 B
JavaScript
Raw Normal View History

2023-12-18 13:12:25 +08:00
'use strict';
module.exports = function reporter(middlewareOptions, options) {
const { log, state, stats } = options;
if (state) {
const displayStats = middlewareOptions.stats !== false;
2024-01-16 21:26:16 +08:00
const statsString = stats.toString(middlewareOptions.stats);
2023-12-18 13:12:25 +08:00
2024-01-16 21:26:16 +08:00
// displayStats only logged
if (displayStats && statsString.trim().length) {
2023-12-18 13:12:25 +08:00
if (stats.hasErrors()) {
2024-01-16 21:26:16 +08:00
log.error(statsString);
2023-12-18 13:12:25 +08:00
} else if (stats.hasWarnings()) {
2024-01-16 21:26:16 +08:00
log.warn(statsString);
2023-12-18 13:12:25 +08:00
} else {
2024-01-16 21:26:16 +08:00
log.info(statsString);
2023-12-18 13:12:25 +08:00
}
}
let message = 'Compiled successfully.';
if (stats.hasErrors()) {
message = 'Failed to compile.';
} else if (stats.hasWarnings()) {
message = 'Compiled with warnings.';
}
log.info(message);
} else {
log.info('Compiling...');
}
};