Webpack-dev-server emits all chunks after every change
Asked Answered
S

1

2

I just implemented hot-reload'ing for our dev environment. My javascript is broken up into a lot of chunks. Every time I make a change to a file all of the chunks get re-submitted. I'm running webpack-dev-server.

Here is an example:

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.

As you can see, only the mychange.jsx file was actually built. However, the rest were still emitted, and the change took a whole 2.4 seconds.

Why is this? Am I missing some setting for webpack?

When I run webpack --watch and make a change, only the proper chunk gets emitted. So, I know it must be something small I'm missing.

Sportscast answered 17/6, 2016 at 2:25 Comment(0)
C
2

Try to add chunks:false in the stats object solves this. ref: https://webpack.github.io/docs/node.js-api.html

devServer: {
    stats: { chunks:false }
}

Here's the relevant code. Looks like the acceptable preset values are: none, errors-only, minimal, normal, verbose and otherwise you can specify your own object:

{
    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
}
Croix answered 21/11, 2016 at 2:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.