write stats report,json into .embark
This commit is contained in:
parent
fd2056da8e
commit
c6e0623f50
|
@ -96,18 +96,48 @@ class WebpackProcess extends ProcessWrapper {
|
|||
};
|
||||
}
|
||||
|
||||
webpack(webpackOptions).run((err, stats) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
if (!detectErrors) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
if (stats.hasErrors()) {
|
||||
return callback(stats.toJson().errors.join("\n"));
|
||||
}
|
||||
callback();
|
||||
webpack(webpackOptions).run((err, stats) => {
|
||||
async.waterfall([
|
||||
function checkStatsError(next) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return next(err);
|
||||
}
|
||||
if (!detectErrors) {
|
||||
return next();
|
||||
}
|
||||
if (stats.hasErrors()) {
|
||||
return next(
|
||||
stats.toJson(webpackOptions.stats).errors.join("\n")
|
||||
);
|
||||
}
|
||||
next();
|
||||
},
|
||||
function writeStatsReport(next) {
|
||||
if (detectErrors) {
|
||||
self._log('info', 'writing file '+ ('dist/stats.report').bold.dim);
|
||||
}
|
||||
fs.writeFile(
|
||||
path.join(fs.dappPath('.embark'), 'stats.report'),
|
||||
stats.toString(webpackOptions.stats),
|
||||
next
|
||||
);
|
||||
},
|
||||
function writeStatsJSON(next) {
|
||||
if (detectErrors) {
|
||||
self._log('info','writing file '+ ('dist/stats.json').bold.dim);
|
||||
}
|
||||
fs.writeFile(
|
||||
path.join(fs.dappPath('.embark'), 'stats.json'),
|
||||
JSON.stringify(stats.toJson(webpackOptions.stats)),
|
||||
next
|
||||
);
|
||||
}
|
||||
], (err) => {
|
||||
callback(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue