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
Moving @import statements breaks CSS rule order #60
When we are concatenating CSS files A, B, and C, the following code can break CSS rule order by importing the dependencies of B ahead of the dependencies of A and by importing the dependencies of C ahead of the dependencies of A and B.
This breaks the expected CSS cascade by changing rule order. When there is a conflict, latter rules of equal specificity win, so by changing the rule order, we change which rule wins.
I see a couple of options here. They are not mutually exclusive.
Only allow the first file in a concat group to have @import rules
If all @import rules reference files on the current site, remove the import rules and inline the contents of the referenced files. If the imports reference external resources, do not inline, and if it is not the first file in the concat group, start a new concat group with this file.
This is a tough one to tackle because we only know about @import statements when generating concatenated style output. Maybe we can update the concat service to do one of the following:
Use @import statements that refer back to the concat service to combine concatenated CSS and @import statements in a way that preserves CSS load order.
Inline things referred to by @import
Number 2 probably should not be done because it is possible servers may provide dynamic content depending on the request.
Number 1 is doable, but it will most likely increase resource load time.
This should be fixed in #99 (test) and #100 (fix). I went with the simple fix of breaking concat boundaries on stylesheets containing @import. They can only be the first sheet in a concat group, and it will make a new group if needed.
Activity
brandonpayton commentedon Jul 23, 2021
This is a tough one to tackle because we only know about
@importstatements when generating concatenated style output. Maybe we can update the concat service to do one of the following:@importstatements that refer back to the concat service to combine concatenated CSS and@importstatements in a way that preserves CSS load order.@importNumber 2 probably should not be done because it is possible servers may provide dynamic content depending on the request.
Number 1 is doable, but it will most likely increase resource load time.
mreishus commentedon Feb 5, 2026
This should be fixed in #99 (test) and #100 (fix). I went with the simple fix of breaking concat boundaries on stylesheets containing
@import. They can only be the first sheet in a concat group, and it will make a new group if needed.