-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Description
Clear and concise description of the problem
In some cases you might have an extra index.html that you want to serve at some nested path, without processing it through Vite. You can put it in a subdirectory of public, e.g. /public/foo/bar/index.html. However, if you do this, it will only be served at /foo/bar/index.html, and crucially not at /foo/bar/. This is different from the Webpack dev server, which will serve index.html files at the path of their containing directory, which caught me by surprise when migrating from Vue CLI to Vite.
https://stackblitz.com/edit/vitejs-vite-944tsu?file=public%2Ffoo%2Fbar%2Findex.html&terminal=dev
Suggested solution
If a subdirectory inside public contains an index.html, the index.html should be served at the path of that directory, either by default or as a configurable option.
Alternative
Instead of putting the directory in public, a possible workaround is to put it in the project root. If you do this it will serve the index file at the directory path. However, this means you need to manually copy the directory over to dist afterwards, which is a bit annoying since the whole point of having public is to automatically copy over files you don't want processed.
Edit: It's also a bit surprising to me that this behavior differs based on whether it's in public or the root
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status