Only move non-resolved @import rules (absolute + external URLs) to top of aggregate stylesheet when also at top in own stylesheet.
E.g.
module1.css
@import url(http://example.com/style1.css);
body {
color: red;
}
@import url(/style2.css);
module2.css
/* comment */
@import url(/style3.css);
body {
color: blue;
}
@import url(http://example.com/style4.css);
In this case, when this stylesheet is aggregated, only style1.css and style3.css should be moved to top of aggregate stylesheet.
Issue fork drupal-646246
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
casey commentedtagging
Comment #2
casey commentedFor more info see: http://www.w3.org/TR/REC-CSS2/cascade.html#at-import
When a stylesheet is aggregated, non-resolved @import rules (like external stylesheets) should be moved to the top, else browsers won't process them.
@import rules that weren't at the top of their actual stylesheet, should not be moved to the top of the aggregate stylesheet either. This is what is currently going wrong.
Not very urgent as long as modules have valid stylesheets without @import rules that aren't at the top.
Comment #3
casey commentedNote that currently also @import rules are moved that occur in comments. e.g.
Result of CSS aggregation:
Comment #4
casey commentedComment #5
wim leersNow that #352951: Make JS & CSS Preprocessing Pluggable has landed, along with better tests for CSS aggregation/minification, it should be a whole lot easier to do this. See #2014851: Drupal CSS preprocessing breaks protocol-relative paths for an example.
Comment #6
dawehnerComment #15
larowlanTriaged as part of Bug Smash Initiative
The code in question is in
\Drupal\Core\Asset\CssCollectionOptimizer::optimizeComment #16
darvanenClosed #646244: Only @import rules at top of aggregated stylesheets should be resolved. as a duplicate of this issue because it's the two combined that create the undesirable effect of bringing otherwise defunct rules into play.
Comment #17
gabrieldaHello, I will work on this issue.
Comment #18
gabrieldaHello, I could not progress much, hence I am unassigning myself