Webpack 4 Generates Empty CSS Vendors Bundle

Do you want to request a feature or report a bug?
Report a bug

What is the current behavior?
Empty CSS Vendors Bundle Being Generated

If the current behavior is a bug, please provide the steps to reproduce.
My config is outputting 2 bundles for both JS and CSS. I want to output one vendors.js and one bundle.js and once bundle.css file. Somehow it is creating an empty vendors.css file. I tried using removeEmptyChunks (which is enabled by default) but it doesn’t do anything. It’ll still emit an empty chunk:

Here is the config:

{
  splitChunks: {
    cacheGroups: {
      default: {
        chunks: 'initial',
        name: 'bundle',
        priority: -20,
        reuseExistingChunk: true,
      },
      vendor: {
        chunks: 'initial',
        name: 'vendor',
        priority: -10,
        test: /node_modules\/(.*)\.js/
      }
    }
  }
}

What is the expected behavior?
Generate 1 bundle for all CSS which is what was happening with the CommonsChunkPlugin and generate 2 bundles for JS, 1 cacheable vendor bundle and 1 commons bundle for everything else plus async route bundles.

If this is a feature request, what is motivation or use case for changing the behavior?
N/A

Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.
Node 9.7.1, Webpack 4.1.1

The issue is replicated in this repository
https://github.com/l0gicgate/webpack-issue-6703

Author: Fantashit

3 thoughts on “Webpack 4 Generates Empty CSS Vendors Bundle

  1. @phiphou how is that a fix? The issue is also on this repo’s end. There’s even an option to ensure that bundles that have a size of zero shouldn’t even be output. I’m not closing this until it is resolved.

Comments are closed.