背景
在 webpack-dev-middleware 的 options 中,有一个名为 stats 的配置,据说是 Node.js 中的一个配置,名为
Output options for the stats
开始不清楚,为了使用 HotModuleReplacement, 就照着 demo 配置了一个 stats: { color: true}
, 感觉完全无用。事实告诉我们,要知其然,也要知其所以然。
在多了这个配置以后,开发就说每次改代码都要全量打包,然后移除这个,他们就说不会了。顿时我也懵了,这有毛关系么?接着就顺着 stats 里面的配置项一个一个配,配的差不多了,才发现居然有配置好的一些常用默认值了:none, errors-only, minimal, normal, verbose,随即就配置一个 normal
,非常好使了。
stats 使用
可以设置为none
, errors-only
, minimal
, normal
, verbose
,当然你也可以依次配置以下选项:
{
hash: false,
version: false,
timings: false,
assets: false,
chunks: false,
modules: false,
reasons: false,
children: false,
source: false,
errors: false,
errorDetails: false,
warnings: false,
publicPath: false
}
API, 就不翻译了
options.context
(string) context directory for request shortening
options.hash
add the hash of the compilation
options.version
add webpack version information
options.timings
add timing information
options.assets
add assets information
options.chunks
add chunk information (setting this to false
allows for a less verbose output)
options.chunkModules
add built modules information to chunk information
options.modules
add built modules information
options.children
add children information
options.cached
add also information about cached (not built) modules
options.reasons
add information about the reasons why modules are included
options.source
add the source code of modules
options.errorDetails
add details to errors (like resolving log)
options.chunkOrigins
add the origins of chunks and chunk merging info
options.modulesSort
(string) sort the modules by that field
options.chunksSort
(string) sort the chunks by that field
options.assetsSort
(string) sort the assets by that field