write stats report,json into .embark

This commit is contained in:
Michael Bradley, Jr 2018-07-19 20:51:46 -05:00 committed by Iuri Matias
parent fd2056da8e
commit c6e0623f50
1 changed files with 40 additions and 10 deletions

View File

@ -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);
});
});
}
}