Skip to content

Commit aa9a1e2

Browse files
committed
fix(server): 修复一些情况compile报错未显示
1 parent 7483355 commit aa9a1e2

File tree

2 files changed

+10
-24
lines changed

2 files changed

+10
-24
lines changed

lib/plugins/compileInfoPlugin.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@
33
var webpack = require("webpack");
44
var formatOutput = require('./tools/format-output.js');
55

6-
function DashboardPlugin(handler) {
7-
this.logContent = null;
8-
}
6+
function DashboardPlugin(handler) {}
97

108
DashboardPlugin.prototype.apply = function (compiler) {
119
var self = this;
1210
var handler = function handler(dataArr) {
1311

14-
if (self.logContent) {
15-
return;
16-
}
17-
1812
dataArr.forEach(function (data) {
1913
switch (data.type) {
2014
// case 'progress':
@@ -64,12 +58,14 @@ DashboardPlugin.prototype.apply = function (compiler) {
6458
}
6559
};
6660
if (stats.hasErrors()) {
67-
error('Failed');
61+
error('Compile Failed.');
62+
} else {
63+
success('Compile Succeed.');
6864
}
6965
// self.logText.log(formatOutput(stats));
7066
// self.moduleTable.setData(formatModules(stats));
7167
// self.assetTable.setData(formatAssets(stats));
72-
self.logContent = formatOutput(stats);
68+
log(formatOutput(stats));
7369
// console.log(formatModules(stats));
7470
// console.log(formatAssets(stats));
7571
break;
@@ -91,10 +87,6 @@ DashboardPlugin.prototype.apply = function (compiler) {
9187
// }
9288
}
9389
});
94-
95-
if (self.logContent) {
96-
log(self.logContent);
97-
}
9890
};
9991

10092
compiler.apply(new webpack.ProgressPlugin(function (percent, msg) {

src/plugins/compileInfoPlugin.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ const webpack = require("webpack");
44
const formatOutput = require('./tools/format-output.js');
55

66
function DashboardPlugin(handler) {
7-
this.logContent = null;
7+
88
}
99

1010
DashboardPlugin.prototype.apply = function(compiler) {
1111
var self = this;
1212
var handler = function(dataArr) {
1313

14-
if(self.logContent) {
15-
return
16-
}
17-
1814
dataArr.forEach(function(data) {
1915
switch (data.type) {
2016
// case 'progress':
@@ -64,12 +60,14 @@ DashboardPlugin.prototype.apply = function(compiler) {
6460
}
6561
};
6662
if (stats.hasErrors()) {
67-
error('Failed');
63+
error('Compile Failed.');
64+
} else {
65+
success('Compile Succeed.')
6866
}
6967
// self.logText.log(formatOutput(stats));
7068
// self.moduleTable.setData(formatModules(stats));
7169
// self.assetTable.setData(formatAssets(stats));
72-
self.logContent = formatOutput(stats);
70+
log(formatOutput(stats));
7371
// console.log(formatModules(stats));
7472
// console.log(formatAssets(stats));
7573
break;
@@ -91,10 +89,6 @@ DashboardPlugin.prototype.apply = function(compiler) {
9189
// }
9290
}
9391
});
94-
95-
if(self.logContent) {
96-
log(self.logContent)
97-
}
9892
};
9993

10094
compiler.apply(new webpack.ProgressPlugin(function(percent, msg) {

0 commit comments

Comments
 (0)