Could the vite plugin automatically modify standar...
# opensavvy
r
Could the vite plugin automatically modify standard
index.html
file to by compatible with it. The file is already copied to vite directory, just some simple regexp filtering would be enough in my opinion.
👀 1
c
That might be possible. I'm not sure what ‘standard’ means though, using
type=module
is definitely more standard than not using it
r
By standard I mean KGP standard 🙂
Webpack compatible
script src="module_name.js"/script
It seems the simplest way for using both vite and webpack at the same time
c
Sure, but I'm not much of a fan of asking the users to create a file that's deliberately not the correct way
Kobweb users don't write the index.html file at all, it's the framework's Gradle plugin that generates it, so they expose a config option there
r
Creating this index.html is still recommended by the Kotlin docs (https://kotlinlang.org/docs/running-kotlin-js.html#run-the-browser-target), so you can assume such files exist in users projects. I think it's better to modify the file automatically instead of asking users to fix their code (but to break standard KGP tooling at the same time).
This would also allow to easily create the correct module version (js/mjs) and to generate import ready for HMR.
You could make it optional functionality, enabled (or disabled) in the plugin configuration.
I'm wiling to at least try to contribute the implementation 🙂
c
Having a
Copy code
vite {
    autoRewriteIndex.set(true)
}
sounds reasonable if it's off by default. The difficult part will be that I don't know how this would interop with the IncrementalSync task.
If you're willing to give it a try, just a heads up, it's unlikely I'll be able to review anything non-trivial in the next ~2 weeks
r