-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: reorder unhandled imports in CSS bundler #19021
Conversation
flow-server/src/main/java/com/vaadin/flow/server/frontend/CssBundler.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sissbruecker do you mind fixing the test module?
flow-server/src/main/java/com/vaadin/flow/server/frontend/CssBundler.java
Show resolved
Hide resolved
flow-server/src/main/java/com/vaadin/flow/server/frontend/CssBundler.java
Outdated
Show resolved
Hide resolved
Doing some additional tests, I found that there is another use case that we might consider: a CSS URL with query string. |
@mcollovati Changed it so that it handles query strings. Now it basically moves all unhandled imports to the top. |
flow-server/src/main/java/com/vaadin/flow/server/frontend/CssBundler.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but please look at the comment on sanitizeUrl()
method and see if it makes sense to you.
There might still be some corner cases where a stylesheet that cannot be inlined is supposed to overwrite rules from a local theme stylesheet, so changing the order might break styling.
But let's merge this fix, and then we will see whether the above is a real use case or not.
Quality Gate passedIssues Measures |
Currently, CssBundler just replaces @imports with inlined file contents and returns the result. That can be problematic if an unprocessed import, for example to an external URL, comes after an inlined import. Now the unprocessed import comes after a regular CSS rule, which is invalid and ignored by the browser.
Currently, CssBundler just replaces @imports with inlined file contents and returns the result. That can be problematic if an unprocessed import, for example to an external URL, comes after an inlined import. Now the unprocessed import comes after a regular CSS rule, which is invalid and ignored by the browser. Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
This ticket/PR has been released with Vaadin 24.4.0.alpha19 and is also targeting the upcoming stable 24.4.0 version. |
Currently
CssBundler
just replaces@import
s with inlined file contents and returns the result. That can be problematic if an unprocessed import, for example to an external URL, comes after an inlined import. Now the unprocessed import comes after a regular CSS rule, which is invalid and ignored by the browser:This change reorders unhandled imports so that they are at the top of the file: