webpack: hide internal assets and source maps in stats

This commit is contained in:
Pooya Parsa 2017-08-01 01:48:40 +04:30
parent 255a944bc9
commit 29ed894c43

View File

@ -373,8 +373,18 @@ export default class Builder extends Tapable {
return reject(err)
}
if (err) return console.error(err) // eslint-disable-line no-console
// Hide internal assets and source maps in stats
const hiddenAssets = [
/.map$/,
/index\..+\.html$/
]
const statsJson = stats.toJson(this.webpackStats, true)
statsJson.assets = statsJson.assets.filter(asset => hiddenAssets.every(e => !e.test(asset.name)))
// Show build stats for production
console.log(stats.toString(this.webpackStats)) // eslint-disable-line no-console
console.log(stats.constructor.jsonToString(statsJson, true))// eslint-disable-line no-console
/* istanbul ignore if */
if (stats.hasErrors()) {
return reject(new Error('Webpack build exited with errors'))