Webpack-dev-server 在每次更改后发出所有块
Webpack-dev-server emits all chunks after every change
我刚刚为我们的开发环境实施了热重载。我的 javascript 被分成了很多块。每次我对文件进行更改时,所有块都会重新提交。我正在 运行ning webpack-dev-server。
这是一个例子:
Hash: 83298e5f7612c91d96ee
Version: webpack 1.13.1
Time: 2417ms
chunk {0} static/js/music/bundle.js (bundle) 1.87 MB
+ 591 hidden modules
chunk {1} static/js/music/1.js 609 kB {0}
+ 103 hidden modules
chunk {2} static/js/music/2.js 179 kB {0}
+ 42 hidden modules
chunk {3} static/js/music/3.js 186 kB {0}
+ 44 hidden modules
chunk {4} static/js/music/4.js 85.5 kB {0}
+ 12 hidden modules
chunk {5} static/js/music/5.js 35.5 kB {0}
+ 9 hidden modules
chunk {6} static/js/music/6.js 835 kB {0}
+ 163 hidden modules
chunk {7} static/js/music/7.js 817 kB {0}
+ 157 hidden modules
chunk {8} static/js/music/8.js 953 kB {0}
+ 189 hidden modules
chunk {9} static/js/music/9.js 11.6 kB {0} {16} {21}
[901] ./js/base/mychange.jsx 9.24 kB {9} [built]
+ 1 hidden modules
chunk {10} static/js/music/bundle2.js (bundle2) 1.87 MB
+ 590 hidden modules
chunk {11} static/js/music/11.js 1.23 MB {10}
+ 216 hidden modules
chunk {12} static/js/music/bundle3.js (bundle3) 1.87 MB
+ 590 hidden modules
chunk {13} static/js/music/13.js 1.23 MB {12}
+ 215 hidden modules
chunk {14} static/js/music/14.js 873 kB {12}
+ 160 hidden modules
chunk {15} static/js/music/15.js 1.22 MB {12}
+ 212 hidden modules
chunk {16} static/js/music/bundle4.js (bundle4) 1.87 MB
+ 590 hidden modules
chunk {17} static/js/music/17.js 566 kB {16}
+ 93 hidden modules
chunk {18} static/js/music/18.js 474 kB {16}
+ 33 hidden modules
chunk {19} static/js/music/19.js 486 kB {16}
+ 33 hidden modules
chunk {20} static/js/music/20.js 955 kB {16}
+ 190 hidden modules
webpack: bundle is now VALID.
如您所见,实际上只构建了 mychange.jsx 文件。但是,其余的还是发出了,变化整整用了2.4秒。
这是为什么?我是否缺少 webpack 的一些设置?
当我 运行 webpack --watch 并进行更改时,只会发出正确的块。所以,我知道这一定是我遗漏的一些小东西。
尝试在统计对象中添加 chunks:false
解决这个问题。参考:https://webpack.github.io/docs/node.js-api.html
devServer: {
stats: { chunks:false }
}
Here's the relevant code。看起来可接受的预设值是: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
}
我刚刚为我们的开发环境实施了热重载。我的 javascript 被分成了很多块。每次我对文件进行更改时,所有块都会重新提交。我正在 运行ning webpack-dev-server。
这是一个例子:
Hash: 83298e5f7612c91d96ee
Version: webpack 1.13.1
Time: 2417ms
chunk {0} static/js/music/bundle.js (bundle) 1.87 MB
+ 591 hidden modules
chunk {1} static/js/music/1.js 609 kB {0}
+ 103 hidden modules
chunk {2} static/js/music/2.js 179 kB {0}
+ 42 hidden modules
chunk {3} static/js/music/3.js 186 kB {0}
+ 44 hidden modules
chunk {4} static/js/music/4.js 85.5 kB {0}
+ 12 hidden modules
chunk {5} static/js/music/5.js 35.5 kB {0}
+ 9 hidden modules
chunk {6} static/js/music/6.js 835 kB {0}
+ 163 hidden modules
chunk {7} static/js/music/7.js 817 kB {0}
+ 157 hidden modules
chunk {8} static/js/music/8.js 953 kB {0}
+ 189 hidden modules
chunk {9} static/js/music/9.js 11.6 kB {0} {16} {21}
[901] ./js/base/mychange.jsx 9.24 kB {9} [built]
+ 1 hidden modules
chunk {10} static/js/music/bundle2.js (bundle2) 1.87 MB
+ 590 hidden modules
chunk {11} static/js/music/11.js 1.23 MB {10}
+ 216 hidden modules
chunk {12} static/js/music/bundle3.js (bundle3) 1.87 MB
+ 590 hidden modules
chunk {13} static/js/music/13.js 1.23 MB {12}
+ 215 hidden modules
chunk {14} static/js/music/14.js 873 kB {12}
+ 160 hidden modules
chunk {15} static/js/music/15.js 1.22 MB {12}
+ 212 hidden modules
chunk {16} static/js/music/bundle4.js (bundle4) 1.87 MB
+ 590 hidden modules
chunk {17} static/js/music/17.js 566 kB {16}
+ 93 hidden modules
chunk {18} static/js/music/18.js 474 kB {16}
+ 33 hidden modules
chunk {19} static/js/music/19.js 486 kB {16}
+ 33 hidden modules
chunk {20} static/js/music/20.js 955 kB {16}
+ 190 hidden modules
webpack: bundle is now VALID.
如您所见,实际上只构建了 mychange.jsx 文件。但是,其余的还是发出了,变化整整用了2.4秒。
这是为什么?我是否缺少 webpack 的一些设置?
当我 运行 webpack --watch 并进行更改时,只会发出正确的块。所以,我知道这一定是我遗漏的一些小东西。
尝试在统计对象中添加 chunks:false
解决这个问题。参考:https://webpack.github.io/docs/node.js-api.html
devServer: {
stats: { chunks:false }
}
Here's the relevant code。看起来可接受的预设值是: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
}