webpack 重建时只能打印发出的文件信息吗?

Can webpack only print emmited files info while webpack rebuilt?

我已经使用这些包来符合 webpack HMR:

webpack 统计信息配置:

stats: {
    assetsSort: 'name',
    children: false,
    chunks: false,
    colors: true,
    warnings: false
  }

使用 webpack-dev-middleware

const _devMiddleware = require('webpack-dev-middleware')(_compiler, {
  publicPath: _webpackConfig.output.publicPath,
  stats: _webpackConfig.stats
});

每次当我 运行 命令 npm run dev 时,控制台将打印如下资产信息:

              scripts/app.bundle.js  1.03 MB  50, 100  [emitted]  [big]  app
           scripts/c-actionsheet.js  28.1 kB  61, 100  [emitted]         c-actionsheet
              scripts/c-alphabet.js   110 kB  55, 100  [emitted]         c-alphabet
                  scripts/c-back.js  18.8 kB  46, 100  [emitted]         c-back
                 scripts/c-basic.js   107 kB  74, 100  [emitted]         c-basic
            scripts/c-build-list.js    30 kB  89, 100  [emitted]         c-build-list
         scripts/c-building-info.js  44.4 kB  83, 100  [emitted]         c-building-info

但是当我使用 webpack HMR 重建我更改过的文件时,控制台将打印所有资产信息,包括 emmited 文件和无关文件,就像:

                scripts/app.bundle.js   1.03 MB  50, 100  [emitted]  [big]  app
             scripts/c-actionsheet.js   28.1 kB  61, 100                    c-actionsheet
                scripts/c-alphabet.js    110 kB  55, 100                    c-alphabet
                    scripts/c-back.js   18.8 kB  46, 100                    c-back
                   scripts/c-basic.js    107 kB  74, 100                    c-basic

我只想知道我修改过的文件,不关心无关的文件信息。

所以,你能帮我让 webpack 只打印这些发出的文件信息吗?

您可以将选项 stats.cachedAssets 设置为 false。这样它只显示实际发出的资产。它似乎没有记录,但这里是 responsible source line and the definition of showCachedAssets.

您的统计信息配置为:

stats: {
    assetsSort: 'name',
    cachedAssets: false,
    children: false,
    chunks: false,
    colors: true,
    warnings: false
}

该选项现在记录在 Configuration - Stats