Task #55690
closed
Make concatenateCss and compressCss generate valid CSS
Added by Thomas Pronold almost 11 years ago.
Updated about 6 years ago.
Description
config.concatenateCss = 1
config.compressCss = 1
do both invalid CSS.
-------------------------------------
Problem with:
config.concatenateCss = 1
output will be:
/* moved by compressor */
@charset "UTF-8";
thats not valid css. @charset "UTF-8"; has to be the first line. no comments allowed before @charset "UTF-8";
-----------------------
Problem with:
config.compressCss = 1
output will be:
@charset"UTF-8";
problem: between @charset and "UTF-8" has to be a space character
Why are you specifying a charset? Does your server deliver a wrong header for the file?
@Markus Klein: There are many reasons to use the @charset-declaration. But I think this is not the question, the declaration exists (http://bit.ly/1vjJCa2) and so TYPO3 should support it. Or not?!
Additionally:
If the charset is defined in more than one stylesheet and the concatenation is enabled, there are multiple charset-definitions.
I think, the best solution is, when
- the concatenation checks if the charset is on top. If not, move it to the top and remove duplicate definitions* and
- the compressor adds the space between the charset and the charset-name (like the font-issue #60675).
*So we can provide the validity and fully support, if the concatenation is on or off.
In typo3/sysext/core/Classes/Resource/ResourceCompressor.php there is functionality to find and move @charset-etc. That's also where the moved-comment is inserted.
I have performed a test with both 6.2.14 and 7.4-dev (latest master);
1. I put in fileadmin the following files:
file1.css
@charset "UTF-8";
/*This is a mere test for comments*/
body{
font-family:sans-serif;
}
file2.css
@charset "UTF-8";
/*This is a mere test for comments*/
body{
font-size:14px;
}
2. TS Setup:
config.concatenateCss = 1
config.compressCss = 1
config.removeDefaultCss=1
page = PAGE
page.includeCSS {
file1 = fileadmin/file1.css
file2 = fileadmin/file2.css
}
page.10 < styles.content.get
3. Resulting file (typo3temp/compressor/merged-whatever.css?whatever):
TYPO3 6.2.14:
@charset"UTF-8";
@charset"UTF-8";
body{font-family:sans-serif}
body{font-size:14px}
TYPO3 7.4-dev:
@charset "UTF-8";@charset "UTF-8";body{font-family:sans-serif;}body{font-size:14px;}
- Target version set to Candidate for patchlevel
- Status changed from New to Under Review
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
- Status changed from Resolved to Closed
Also available in: Atom
PDF