webpack dev stats

本贴最后更新于 2690 天前,其中的信息可能已经时异事殊

背景

在 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

  • webpack

    webpack 是一个用于前端开发的模块加载器和打包工具,它能把各种资源,例如 JS、CSS(less/sass)、图片等都作为模块来使用和处理。

    41 引用 • 130 回帖 • 297 关注
  • stats
    1 引用
  • 日志
    44 引用 • 105 回帖

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...
Vanessa
我们终此一生,就是要摆脱他人的期待,找到真正的自己。 昆明