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

Add stripping of @charset lines #83

Merged
merged 3 commits into from
Nov 19, 2023

Conversation

backspace
Copy link
Contributor

My asset pipeline changed a bit and the generated CSS was updated to start with this:

@charset "UTF-8";

This caused Premailex to crash when inlining styles, like you can see here:

     ** (FunctionClauseError) no function clause matching in Floki.Selector.Parser.do_parse/2

I was able to work around it by adding a Webpack plugin to strip the @charset line from the CSS, but I figured this might happen to others so here’s a draft fix.

It seems hackish, though maybe unavoidable considering #30? I’m also unsure why @keyframes and the like wouldn’t cause similar problems.

@danschultzer
Copy link
Owner

danschultzer commented Nov 19, 2023

Yeah, other at-rules will fail as well. I'm gonna merge this, and release fix, but I think I need to build a proper CSS parser instead. Though it can be forced to work in most cases, the regex is hacky.

@danschultzer danschultzer merged commit 8a21ed9 into danschultzer:main Nov 19, 2023
5 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants