Skip to content

[AssetMapper] Fix: also download files referenced by url() in CSS #52725

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

Merged
merged 1 commit into from
Nov 25, 2023

Conversation

weaverryan
Copy link
Member

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #52620
License MIT

Hi!

@tacman found another situation where our "asset downloader" wasn't complete.

If we're downloading a CSS file, it may reference other files via url(). In #52620, these were font files, but they could be images or even other CSS Files. Currently, we do NOT download these, so the local references fail. This fixes that. I tried to keep the PR as small as possible, given the late stage of 6.4. But this is a bug fix: the downloader currently doesn't work for CSS files with url() inside.

Tested locally on ux.symfony.com with the bootstrap-icons package.

Cheers!


if ($extraFileResponses) {
goto download_extra_files;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This got a bit complex because it needs to be recursive (first.css has a url() pointing to second.css, so then we need to check second.css also for url()). However, the recursion is tested, though I don't know of any examples "in the wild" to try this on.

I imagine vendor packages importing one css file from another would be quite rare because CSS files are always packaged into one to reduce requests (even with HTTP2 this is still important for CSS files, as they are page-render-blocking and you can't discover that you need to download second.css until you download first.css).

@fabpot fabpot force-pushed the asset-mapper-download-font-files branch from 69b0e16 to ca90ed8 Compare November 25, 2023 08:29
@fabpot
Copy link
Member

fabpot commented Nov 25, 2023

Thank you @weaverryan.

@fabpot fabpot merged commit 9b70fbf into symfony:6.4 Nov 25, 2023
@weaverryan weaverryan deleted the asset-mapper-download-font-files branch November 25, 2023 12:54
This was referenced Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants