Skip to content

"Composes" duplicating css (again) #1037

Closed
@vlazh

Description

@vlazh
  • webpack Version: 4.19.1
  • css-loader Version: 3.4.1

It's copy of #772 but with latest css-loader.

Expected Behavior

It shouldn't duplicate css class.

Actual Behavior

When a class name within a css file is shared using "composes" in a 2 degree level, it gets duplicated (when each class has its own file).

For example (each class has its own css file):

Case 1 (composes in 1 degree level)
"primary-button" which composes "button" and;
"secondary-button" which composes "button".
This case is ok, and nothing gets duplicated.

Case 2 (composes in 2 degree level)
"next-button" which composes "primary-button" which composes "button" and;
"back-button" which composes "secondary-button" which composes "button".
On this case, the "button" class gets duplicated.

The second case was tested with the following plugins:
style-loader (see print): https://raw.githubusercontent.com/ivensgoncalves/Webpack_StylesDuplication/master/prints/style-loader.png
mini-css-extract-plugin (see print): https://raw.githubusercontent.com/ivensgoncalves/Webpack_StylesDuplication/master/prints/mini-css-extract-plugin.png

On both plugins the "button" class got duplicated.

Code

With latest css-loader:
https://github.com/vlazh/Webpack_StylesDuplication

How Do We Reproduce?

A minimal reproducible project with this issue:
https://github.com/vlazh/Webpack_StylesDuplication

To test with style-loader, execute "npm run start1"
To test with mini-css-extract-plugin, execute "npm run start2"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions