-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
There is no way to disable/filter preload #3133
Comments
hoping to have an option to customize |
After #4097, preload is now disabled for library mode. @xhebox if your issue is solved by this change, please close this issue. If not, could you provide more information about your use case. We discussed adding an option for preload with the team and we would like to avoid adding more configuration at this point regarding this feature. |
In short, I want a complete disable switch for all preload things, at least. |
Can you explain why you need this feature? What problems can it solve? |
I have not use vite now, but I met several use cases:
|
I think there are several scenarios where you want to control preload independently from library mode. To give an example: I'm importing a web component into a Svelte project. Both are projects built with Vite. The web component is hosted on a different domain than my Svelte project, but all preloads are pointing to the Svelte project and hence result in a 404. I don't know if there's a combination of options that fixes my use case. When I build the web component in library mode, my chunks won't have hashes in the filename, but I need them for cache-busting. The Svelte app needs the HTML template as an entry point, so that's no option either. A separate option to disable preload would definitely make this easier. I guess that my particular case could also be seen as a bug: my web component is imported from an URL, so the same should be used for the preloads - not a relative path. |
I'm currently having to run a transform on top of the generated HTML to strip out the preload tags. It's not limited to JS either, it's preloading SVG's etc. I think a config option to simply disable the behaviour would be a welcome addition. |
Would love to see your workaround to transform the generated HTML |
For one, importmaps I've created a managed handler to remove the modulepreload entries in index.html dynamically and inject an importmap. Now I'm finding there is yet another preloader. |
A big one: Giant project! there is a way to disable it ? |
I found the prefilter needs to leave the CSS references, because it turns out, the prefilter is the only way they even load. Here is the regex replace that I use to remove the JS prefilter, but keep the CSS prefilter:
|
For the folks involved in this issue, would you check if #9938 would cover your needs? Please give us feedback if you test it in your projects. |
@patak-dev I was trying the Otherwise it works great, fixed most of my issues in #9933. Only the issue with double |
Clear and concise description of the problem
Vite now will not only insert preload directives to the HTML file by the build-html plugin, but also preload helpers for all non-HTML entries by the ImportAnalysis plugin.
And sometimes, you really want lazy loading rather than preloading everything, even for the main HTML entry. There should be a method to control the preload directives generation and preload helper insertion.
Suggested solution
A boolean switch in the config file is enough for me. But maybe a hook function will be better.
The text was updated successfully, but these errors were encountered: