Skip to content
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

@charset "UTF-8" moved below @import #436

Closed
SLKnutson opened this issue Nov 2, 2020 · 6 comments
Closed

@charset "UTF-8" moved below @import #436

SLKnutson opened this issue Nov 2, 2020 · 6 comments

Comments

@SLKnutson
Copy link

SLKnutson commented Nov 2, 2020

Previously opened an issue with angular, but I've isolated the issue to this library.
The incoming css looks like

@charset "UTF-8";
@import url("https://fonts.googleapis.com/css?family=Raleway:400,500,600,700");
.force-unicode {
  content: "\f103"
}

but after passing through this plugin, the @import is listed above the @charset. @charset needs to be listed first to work.

Thanks!

@RyanZim
Copy link
Collaborator

RyanZim commented Nov 2, 2020

I'm not understanding the issue here; the input css does not contain @charset at all, so where does the @charset come from?

@SLKnutson
Copy link
Author

@RyanZim I messed up the markdown. Fixed now.

@RyanZim
Copy link
Collaborator

RyanZim commented Nov 2, 2020

Oof, yeah, that's a bug; investigating...

RyanZim added a commit that referenced this issue Nov 4, 2020
@RyanZim
Copy link
Collaborator

RyanZim commented Nov 4, 2020

PR with a failing test to replicate this bug: #438. I've made some progress tracking down why this happens, but still haven't figured out the right way to fix it. Feel free to take a stab at it yourself, BTW, otherwise, I'll keep working on this as I get time.

@SLKnutson
Copy link
Author

There is probably no right answer on how to handle charset since you could theoretically find them anywhere in the root file, or imported files, but at the end of the day there needs to be at most one. Looks like all files that get @imported in get brought in as utf-8, but the root passed in css file contents could be any encoding, so it may not be safe to assume that everything could have @charset "UTF-8" slapped at the top.

RyanZim added a commit that referenced this issue Dec 12, 2020
RyanZim added a commit that referenced this issue Dec 12, 2020
@RyanZim
Copy link
Collaborator

RyanZim commented Dec 12, 2020

OK, got a half-decent solution here: #447 Take a look, and let me know what you think.

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