You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems strange before i read the code of vite. I just found the reason in the below function.
If the pre hook returns tags, these tags will be injected after all hooks exec done. However, in this way, post transformIndexHtml hooks will never controller the real index.html!
I think it's a bug so i report it. Looking forward to be replied : )
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
This makes sense, the tags should be added to the html before the next transform. I wonder if there's a reason it is now, but if we do change it, it could be a breaking change. Perhaps one safe way for now is if we pass those tag arrays into the ctx object, and manipulate from there.
Describe the bug
I'm using the transformIndexHtml hook to replace all
src
values of<script>
or<link>
, just like this:It works well until i use the
@vitejs/plugin-legacy
plugin.@vitejs/plugin-legacy
will insert polyfills to the end ofindex.html
, but i can't get it in transformIndexHtml hook.For example the legacy index.html looks like:
I actually get in my transformIndexHtml hook:
It seems strange before i read the code of vite. I just found the reason in the below function.
If the pre hook returns tags, these tags will be injected after all hooks exec done. However, in this way, post transformIndexHtml hooks will never controller the real index.html!
I think it's a bug so i report it. Looking forward to be replied : )
Reproduction
https://github.com/helianthuswhite/vite-test-demo
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: