Skip to content

Conversation

buduchail
Copy link

We had a problem when minimizing CSS with optimizations on but processing of import rules off. Some optimized selectors would end up above import rules, thus ignoring imported fonts in the generated CSS. This change fixes the problem in our environment.

@@ -634,6 +634,10 @@ AdvancedOptimizer.prototype.restructure = function (tokens) {

var position = tokens[0] && tokens[0].kind == 'at-rule' && tokens[0].value.indexOf('@charset') === 0 ? 1 : 0;
for (; position < tokens.length - 1; position++) {
if (!tokens[position] || tokens[position].kind != 'at-rule' || tokens[position].value.indexOf('@import') !== 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@buduchail can we do it in one step together with checking for comments? Otherwise 💯

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have combined the two checks together now. Thanks!

@jakubpawlowicz
Copy link
Collaborator

@buduchail I've merged it manually simplifying the checks - the credit still goes to you! Thanks for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants