我已经使用这些包来遵守 webpack HMR:
- webpack@2.2.1
- webpack-dev-middleware@1.10.1
- webpack-hot-middleware@2.17.1
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
});
每次我运行 command 时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 只打印这些 emmited 文件信息吗?