vitejs / vite

Next generation frontend tooling. It's fast!
http://vitejs.dev
MIT License
67.59k stars 6.09k forks source link

Ability to provide a root_file instead of a root directory #6668

Closed malmod closed 2 years ago

malmod commented 2 years ago

Clear and concise description of the problem

In my current use case, I'm using vite to build multiple SPA targets from a monorepo.

I can have multiple root directories, but each directory needs to contain redundant data as configuration is the same for all directories, the only difference is the root index.html.

Also, for some reason, using windicss plus svelte does also not work well with subdirectories, as the style is not properly built when using a root directory which is not the current directory. Although this is probably a bug with windicss, it illustrates however the difficulties of having multiple directories for other packages which may not support this well.

Suggested solution

The easy solution would be to provide a root_file parameter which is simply the path to index.html.

All other parameters and configuration files are taken from the main current directory.

Alternative

No response

Additional context

No response

Validations

Bigfish8 commented 2 years ago

You can write a plugin and implement it in transformIndexHtml hook.

malmod commented 2 years ago

Thanks for the plugin suggestion.

If I can't use vite-plugin-html directly, I can probably implement something close.