Skip to content
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: allow ssr css preloads in preload-helper #1734

Merged
merged 3 commits into from
Jan 26, 2021

Conversation

bompus
Copy link
Contributor

@bompus bompus commented Jan 26, 2021

I came across this bug while I was experimenting with preloading css that I know would end up being loaded during app execution.

In my app, I know various components that my page is going to load ahead of time, so I use the manifest.json to inject link[rel=modulepreload/preload][as=script/style] preloads in <head> before delivering it to the browser that I know will be loaded later on.

In built index.html file, if you add css preloads for the same href as the app is going to load, the app does not append link[rel="stylesheet"] to the document. This is due to a conditional in importAnaysisBuild

Example:

<head>
   ...
   <link rel="preload" as="style" href="/assets/MyComponent.32451e5d.css">
   ...
</head>

During app page execution, the following should have been appended to the document head, but was not:

<link rel="stylesheet" href="/assets/MyComponent.32451e5d.css">

This PR fixes this issue and also includes some performance improvements to the surrounding logic.

@yyx990803 yyx990803 merged commit 1dfda16 into vitejs:main Jan 26, 2021
@bluwy bluwy mentioned this pull request Aug 2, 2022
9 tasks
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