Fix incorrect cascade layer order when some resources can not be inlined #574
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes the original problem described in #567 (comment)
The root cause is that all nodes are added to either the
imports
orbundle
array inpostcss-import/lib/parse-styles.js
Lines 36 to 37 in d43ca15
While
@layer
statements (those without a rule body) can precede@import
.To fix this issue I've added a new statement type for layers and added the needed mechanics to apply conditions to these. To express conditional
@layer
statements before other@import
statements, or@layer
statements that end up in between other@import
statements we use base64 encoded stylesheets:@import 'data:text/css;base64,QGxheWVyIGxheWVyLWJldGE=' print;
is equivalent to@media print { @layer layer-beta }
but is valid before other@import
statementsI am unsure if it fixes all other reported examples as I don't have reproductions for those. I suggest they test out the fix (if/when it lands) and file new issues if they still encounter problems.
I verified the fix by re-testing with https://github.com/romainmenke/css-import-tests
With the patch applied 4 more test cases pass, without regressions in other cases.