Skip to content

splitChunks can create initial chunks that are empty after CSS extraction #7300

@edmorley

Description

@edmorley

Bug report

What is the current behavior?

The splitChunks feature (using chunks: 'all') doesn't take into account CSS extraction (via mini-css-extract-plugin) when deciding whether to create a new inital chunk. A new chunk can end up being created that is empty (other than the webpack functions) and under the default 30KB splitChunks.minSize threshold so shouldn't have been created.

eg:
dist/vendors~pageA~pageB.js

For webpack build log output see:
https://github.com/edmorley/testcase-webpack-splitchunks-css#actual

If the current behavior is a bug, please provide the steps to reproduce.

  1. git clone https://github.com/edmorley/testcase-webpack-splitchunks-css.git
  2. yarn install
  3. yarn build

What is the expected behavior?

There is no dist/vendors~pageA~pageB.js chunk generated, since after the CSS is extracted, there should be no common JS code between the two pages.

Other relevant information:
webpack version: 4.8.3
Node.js version: 10.1.0
Operating System: Windows 10
Additional tools: mini-css-extract-plugin@0.4.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions