forked from electrode-io/electrode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack-dev-reporter.ts
37 lines (30 loc) · 1.03 KB
/
webpack-dev-reporter.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* eslint-disable global-require, @typescript-eslint/no-var-requires */
const notifyBundleValid = require("../util/notify-bundle-valid");
/* eslint max-statements: 0 */
function webpackDevReporter(reporterOptions) {
const state = reporterOptions.state;
const stats = reporterOptions.stats;
const options = reporterOptions.options;
const logger = require("@xarc/app-dev/lib/logger");
if (state) {
let displayStats = !options.quiet && options.stats !== false;
if (displayStats && !(stats.hasErrors() || stats.hasWarnings()) && options.noInfo) {
displayStats = false;
}
if (displayStats) {
logger.info(stats.toString(options.stats));
}
if (!options.noInfo && !options.quiet) {
let errMsg = ".";
if (!stats.hasErrors()) {
notifyBundleValid();
} else {
errMsg = " but there were errors.";
}
logger.info(`webpack: bundle is now VALID ${errMsg}`);
}
} else {
logger.info("webpack: bundle is now INVALID.");
}
}
module.exports = webpackDevReporter;