lightningcss: Lightning CSS doesn't escape `content: "\..."`

We have @charset "UTF-8"; in our CSS which Lightning CSS is skipping when bunding/minifying the styles. Without it, it’s possible to encounter issues with displaying unicode like in https://github.com/parcel-bundler/lightningcss/issues/164. There are other ways to insert the character encoding like HTTP headers and the HTML but this is not possible for people in some use cases.

Is it possible to respect the @charset rule?

I’ve also prepared a Playground link demonstrating the issue.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 16 (4 by maintainers)

Commits related to this issue

Most upvoted comments

This is something I’ve encountered too. I’m currently unsure what causes Chrome to suddenly think that the CSS file isn’t UTF-8, but I have a hunch that it’s something to do with devtools.

There’s a discussion over in the Font Awesome repo about a similar issue: https://github.com/FortAwesome/Font-Awesome/issues/17644 The consensus there seems that @charset "UTF-8"; doesn’t always solve the issue, so it would be good if Lighning CSS left characters in their encoded form or had an option to toggle it.