我刚刚为我们的开发环境实现了热重载。我的 javascript 被分成很多块。每次我对文件进行更改时,所有块都会重新提交。我正在运行 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 并进行更改时,只会发出正确的块。所以,我知道它一定是我缺少的一些小东西。