Open fcrozatier opened 3 months ago
not a bug, kit handles html itself. see https://github.com/sveltejs/kit/discussions/8269
Maybe we could log a warning if we detect plugins with that hook?
But isn't kit just a Vite plugin, how come it can intercept other plugins / prevents them from running?
In a raw Vite project we can have a sequence of plugins with the same hook, and have for example many transformIndexHtml
plugins doing each their own thing. So in principle even if kit handles html, this should not prevent further transformation right?
Kit doesn't prevent it from running, but Vite never tries to invoke it. The problem with that hook is that it's meant for a different app type: https://vitejs.dev/config/shared-options.html#apptype. Perhaps Vite's docs should be updated with regards to that plugin hook. Your plugin is attempting to modify the title at build time, but the title is generated at runtime so that won't work. You should use SvelteKit's handle
instead.
Oh I see so Kit modifies Vite config's appType
to custom
which implies that transformIndexHtml
doesn't run since for this app type it's expected that the html transforms are handled at the framework level (the "html middlewares").
Then it's definitely a documentation thing, maybe a quick note on the plugin API side could explain this.
Which also means we can't benefit from framework agnostic transformIndexHtml
hooks from the ecosystem. Too bad!
Thank you for the explanation!
@benmccann I'm a bit confused, here's the answer on the related Vite PR:
appType
doesn't affect iftransformIndexHtml
is called, it's up to the frameworks if they callserver.transformIndexHtml
. If they don't, then the hook will not be called
So it seems there could still be something to do on kit's end? We could choose to support this hook or just document that it's not supported.
handle
I would love to see this supported, as for example handling favicons is painful every time I'm building a site with SvelteKit and there are really lots of different use-cases and plugins. A couple of useful ones gathered from other issues here: https://github.com/josh-hemphill/vite-plugin-favicon https://github.com/ZhongxuYang/vite-plugin-version-mark https://www.npmjs.com/package/vite-plugin-webfont-dlg
Describe the bug
I'm not sure if this is desired or not or a documentation thing. For some reason Vite
transformIndexHtml
plugins do not run.Reproduction
Just paste this inside a
vite.config.ts
Logs
No response
System Info
Severity
annoyance
Additional Information
Why is this happening?