You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inlining CSS from @import doesn't strip @charset #640
When inlining css files included by an @import, the @charset declaration at the top of the imported css file are not stripped out before it is included.
It seems like the @charset should be stripped from the output file. Are there any problems with that? Is there a good way to end up with the correct end result?
Is it correct to set the charset in the main file and leave it out of the imported files bucause the charset in main.css should applies to imported stylesheets as well?
I'm affected by this as well. We have to add @charset statements to all our files to get our IDE to recognise the encoding properly and the optimizer doesn't strip them when they appear repeatedly.
This doesn't seem to cause any problems in browsers yet but it'd still be good to end up with valid CSS just to be on the safe side.
You can run sed as part of you build step to remove the @charset lines but you may have to make sure all your css files end with newlines or you may run into problems. 😖
The CSS minifications in r.js are pretty basic, and there are a bunch of rules like this one that it does not understand.
In the future, I would likely break the CSS minification out into another tool, as I do not want to have to put the burden on r.js to carry all of that weight.
So putting this in the 3.0 bucket, mostly as a reminder to separate out the CSS stuff to another tool, maybe even suggest other tools if they are more robust.
Activity
ianlewis commentedon Mar 6, 2014
This seems to answer my question. Is this right?
http://stackoverflow.com/questions/6422390/importing-css-with-import-in-conjunction-with-charset
Is it correct to set the charset in the main file and leave it out of the imported files bucause the charset in main.css should applies to imported stylesheets as well?
main.css
Shepard commentedon Mar 10, 2014
I'm affected by this as well. We have to add @charset statements to all our files to get our IDE to recognise the encoding properly and the optimizer doesn't strip them when they appear repeatedly.
This doesn't seem to cause any problems in browsers yet but it'd still be good to end up with valid CSS just to be on the safe side.
ianlewis commentedon Mar 10, 2014
You can run sed as part of you build step to remove the @charset lines but you may have to make sure all your css files end with newlines or you may run into problems. 😖
sed -e 's/^@charset .*$//g'
jrburke commentedon Mar 18, 2014
The CSS minifications in r.js are pretty basic, and there are a bunch of rules like this one that it does not understand.
In the future, I would likely break the CSS minification out into another tool, as I do not want to have to put the burden on r.js to carry all of that weight.
So putting this in the 3.0 bucket, mostly as a reminder to separate out the CSS stuff to another tool, maybe even suggest other tools if they are more robust.