Skip to content

Conversation

manzt
Copy link
Collaborator

@manzt manzt commented Jul 13, 2021

Normally vite handles a request for index.html, but vite-plugin-virtual-html-template intercepts requests for .html and doesn't allow vite to inject a runtime client to handle auto-refreshing.

This PR adds a minimal plugin to inject the /@vite/client code during dev and force and auto-refresh. It's not perfect, but it's better than the existing solution.

@flekschas
Copy link
Owner

Thanks for the PR! I wonder, does Vite not like the template approach? Maybe we should restructure the examples to have better support by Vite? Right now it feels like we replaced a stable working dev setup with a fast but brittle solution. Don't get me wrong, I like the speediness of Vite but with Webpack everything just worked without any special setups.

Unfortunately, I don't have much experience with Vite but I'll poke around a little tonight.

@manzt
Copy link
Collaborator Author

manzt commented Jul 13, 2021

I wonder, does Vite not like the template approach?

Yeah this is the primary "issue". Vite out of the box assumes 1:1 mapping of files on disk to your app entry points. Plugins can help with some of this, but plugin ecosystem is young.

Maybe we should restructure the examples to have better support by Vite?

I thought about this as well, but the issue is that we really do want a template of some type for the examples. Making vite (without any plugins) work nicely would entail creating separate x.html.

Unfortunately, I don't have much experience with Vite but I'll poke around a little tonight.

Have a look at my latest changes and let me know what you think. I don't mind reverting if that is your preference!

"prerelease": "rm -rf dist/*; npm run build; zip -r dist.zip dist",
"pretest": "npm run lint",
"start": "vite",
"preview": "vite preview",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vite build && vite preview lets you view a production version of the site locally.

@manzt manzt changed the title [wip] vite auto-refresh vite auto-refresh Jul 13, 2021
@manzt
Copy link
Collaborator Author

manzt commented Jul 14, 2021

Hmm really odd error in the CI. I tried to track I down earlier to no avail..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants