-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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: sequential injection of tags in transformIndexHtml (#5851) #6901
Conversation
same question, can't wait. |
@tyouzu1 As a workaround, you can currently use the |
Already seen. No test yet. Thanks anyway |
I think this makes sense, it is already added for discussion in a team meeting. We'll try to get to it before the v3 release. |
Just to clarify. This PR changes the order slightly. For example, if there are two plugins like this: {
plugins: [
{
name: 'hook1',
transformIndexHtml(html) {
return [
{ tag: 'meta', children: 'hook1-pre', injectTo: 'head-prepend' },
{ tag: 'meta', children: 'hook1', injectTo: 'head' }
]
}
},
{
name: 'hook2',
transformIndexHtml(html) {
return [
{ tag: 'meta', children: 'hook2-pre', injectTo: 'head-prepend' },
{ tag: 'meta', children: 'hook2', injectTo: 'head' }
]
}
}
]
} <!-- output before this PR -->
<head>
<meta>hook1-pre</meta>
<meta>hook2-pre</meta>
<meta>hook1</meta>
<meta>hook2</meta>
</head>
<!-- output after this PR -->
<head>
<meta>hook2-pre</meta>
<meta>hook1-pre</meta>
<meta>hook1</meta>
<meta>hook2</meta>
</head> |
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.
The new order is what I would expect 👍🏼
I would consider the order change a bug fix.
Description
The built-in
html
plugin provides atransformIndexHtml
hook for all plugins, which inputs contents ofindex.html
and outputs modified contents and some tags to inject. But alltags
to inject are injected after all plugins'transformIndexHtml
hook, so tags injected by previous plugins are not visible to next ones.It closes #5851.
Additional context
I changed the code to handle tags injection after each plugin's hook, so the performance inevitably degrades. Is it acceptable? If not, should we use other ways such as adding another parameter to
transformIndexHtml
to receive tags that previous plugins want to inject?What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).