Skip to content

Multi entrypoint styles duplication with preprocessors like stylus #1207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mytecor opened this issue Oct 10, 2020 · 14 comments
Closed

Multi entrypoint styles duplication with preprocessors like stylus #1207

mytecor opened this issue Oct 10, 2020 · 14 comments

Comments

@mytecor
Copy link

mytecor commented Oct 10, 2020

  • Operating System: Windows 10 2004
  • Node Version: 14.11.0
  • NPM Version: 6.14.8
  • webpack Version: 4.44.2
  • css-loader Version: 4.3.0
  • stylus-loader Version: 4.1.1

Expected Behavior

.box,.child,.test{border-width:2px;border-style:solid;padding:0 20px;margin:0 6px;max-width:400px}
.child{border-style:dotted;border-color:#008000}
.test{border-color:#f00}

Actual Behavior

.box{border-width:2px;border-style:solid;padding:0 20px;margin:0 6px;max-width:400px}
.box,.child{border-width:2px;border-style:solid;padding:0 20px;margin:0 6px;max-width:400px}
.child{border-style:dotted;border-color:#008000}
.box,.test{border-width:2px;border-style:solid;padding:0 20px;margin:0 6px;max-width:400px}
.test{border-color:#f00}

How Do We Reproduce?

Repo

yarn build
@mytecor
Copy link
Author

mytecor commented Oct 10, 2020

Or is it a bug in extract-css-chunks-webpack-plugin?

@mytecor mytecor changed the title Multi entrypoint styles duplication Multi entrypoint styles duplication with preprocessors like stylus Oct 10, 2020
@alexander-akait
Copy link
Member

Yes, it is bug on extract-css-chunks-webpack-plugin side, I recommend to use mini-css-extract-plugin

@mytecor
Copy link
Author

mytecor commented Oct 10, 2020

I get the same output with mini-css-extract-plugin and style-loader

@alexander-akait
Copy link
Member

Okay, I will look at this in near future, but mostly it is configuration problems, or you duplicate modules

@alexander-akait
Copy link
Member

My actual result is:

.box{border-width:2px;border-style:solid;padding:0 20px;margin:0 6px;max-width:400px}
.box,.child{border-width:2px;border-style:solid;padding:0 20px;margin:0 6px;max-width:400px}.child{border-style:dotted;border-color:#008000}
.box,.test{border-width:2px;border-style:solid;padding:0 20px;margin:0 6px;max-width:400px}.test{border-color:#f00}

No problems, look at dist directory

@mytecor
Copy link
Author

mytecor commented Oct 13, 2020

I expected to see this result: single entry

@alexander-akait
Copy link
Member

@midnightcoder-pro you need to setup minificator https://github.com/webpack-contrib/css-minimizer-webpack-plugin, CSS minification is out of scope css-loader

@mytecor
Copy link
Author

mytecor commented Oct 13, 2020

In my opinion, this is a loss of context, not a minimization task. Stylus doesn't know anything about entry points and processes them separately.
css-minimizer-webpack-plugin gives an incorrect result in comparison with single entry point setup

@alexander-akait
Copy link
Member

@midnightcoder-pro #1207 (comment) it is what stylus-loader returns to css-loader, we don't touch your CSS

@mytecor
Copy link
Author

mytecor commented Oct 13, 2020

But this part is handled by css-loader?

import './parent.styl'
import './child.styl'
import './test.styl'

Aren't these three separate launches of the stylus-loader?

@alexander-akait
Copy link
Member

What is the problem? We handle CSS returned from style-loader, we don't merge CSS, we don't change it, we just handle url/@import

@mytecor
Copy link
Author

mytecor commented Oct 13, 2020

Expected Behavior

.box,.child,.test{border-width:2px;border-style:solid;padding:0 20px;margin:0 6px;max-width:400px}
.child{border-style:dotted;border-color:#008000}
.test{border-color:#f00}

Actual Behavior

.box{border-width:2px;border-style:solid;padding:0 20px;margin:0 6px;max-width:400px}
.box,.child{border-width:2px;border-style:solid;padding:0 20px;margin:0 6px;max-width:400px}
.child{border-style:dotted;border-color:#008000}
.box,.test{border-width:2px;border-style:solid;padding:0 20px;margin:0 6px;max-width:400px}
.test{border-color:#f00}

Is it stylus-loader or style-loader problem?

@alexander-akait
Copy link
Member

This is a problem neither style-loader or style-loader, this result:

.box{border-width:2px;border-style:solid;padding:0 20px;margin:0 6px;max-width:400px}
.box,.child{border-width:2px;border-style:solid;padding:0 20px;margin:0 6px;max-width:400px}.child{border-style:dotted;border-color:#008000}
.box,.test{border-width:2px;border-style:solid;padding:0 20px;margin:0 6px;max-width:400px}.test{border-color:#f00}

was returned from stylus, so you need to stylus about this

@mytecor
Copy link
Author

mytecor commented Oct 13, 2020

Okay, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants