mini-css-extract-plugin icon indicating copy to clipboard operation
mini-css-extract-plugin copied to clipboard

Specifying maxSize parameter causes incorrect ordering of CSS files

Open tstibbs opened this issue 5 years ago • 3 comments

  • Operating System: Ubuntu 16.04.2 LTS
  • Node Version: v12.14.1
  • NPM Version: 6.14.5
  • webpack Version: 4.43.0
  • mini-css-extract-plugin Version: 0.9.0

Expected Behavior

You should be able to set optimization.splitChunks.maxSize to limit the size of chunks.

Actual Behavior

Setting optimization.splitChunks.maxSize messes up the order that css is loaded on the page.

Code

Having the following in webpack.config.js will cause mis-ordering in some situations.

optimization: {
  splitChunks: {
    minSize: 1,
    maxSize: 2,
  },
},

How Do We Reproduce?

Smallest example I can come up with: https://github.com/tstibbs/mini-css-extract-bug

tstibbs avatar Jul 14 '20 11:07 tstibbs

This is a problem. We don't guarantee order of chunks and if your CSS depends on cross-module order that won't work. I'm not aware of any simple fix to that. Do not rely on CSS rules order between modules. Sorry for delay

alexander-akait avatar Feb 15 '21 13:02 alexander-akait

@alexander-akait are you saying that you don't guarantee order of chunks under any circumstance - i.e. you're saying that it's just luck that it's currently working for me even when not setting maxSize?

tstibbs avatar Mar 05 '21 08:03 tstibbs

@tstibbs Yes, because in code you have right order, but we don't guarantee order

alexander-akait avatar Mar 05 '21 11:03 alexander-akait

THe same problem - https://github.com/webpack-contrib/mini-css-extract-plugin/issues/959, bug on HtmlWebpackPlugin side, because we export the valid order

alexander-akait avatar Nov 29 '22 17:11 alexander-akait