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

Plugin can generate invalid output CSS bundle from valid input CSS files (misplaced @charset from concatenation) #54

Open
alecglassford opened this issue Dec 16, 2022 · 1 comment

Comments

@alecglassford
Copy link

alecglassford commented Dec 16, 2022

From valid CSS files (e.g. that start with @charset "utf-8";), this plugin can generate an invalid CSS output (e.g. @charset "utf-8"; appears multiple times and/or somewhere other than the start of the file).

References:

I've created a minimal reproduction of this issue: https://gist.github.com/alecglassford/7ef56480d4aa620b0f753a20236773d4

As a point of comparison, Vite handles this scenario by hoisting the first @charset statement it encounters to the top of the CSS output and removing any additional @charset statements: vitejs/vite#7678 and vitejs/vite#7691


As a side note, I suspect #36 is a similar issue: concatenating CSS inputs can lead to @import appearing in the middle of the output CSS; this at-rule should also only appear at the top of a file.

@thgh
Copy link
Owner

thgh commented Jul 16, 2023

Do you mind checking out https://www.npmjs.com/package/rollup-plugin-import-css or https://www.npmjs.com/package/rollup-plugin-styles and see if those work for you?

I'm using higher level frameworks nowadays so won't fix bugs. Happy to merge a fix though!

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