Open filips123 opened 1 year ago
@filips123 It was intentional at the time to prevent people from accidentally causing file conflicts, but it has been reported several times, so I think I'll make it configurable. Should be as simple as flipping the parameters of vite.mergeConfig
in a few places.
I'll try and get to it this week.
Alright, working on this now, but a couple of comments:
The first problem is that my custom fileNames patterns are not respected for all files (CSS files are still in the root directory)
Even if you set customassetFileNames
, entryFileNames
, and chunkFileNames
options, Vite will not respect your options for all files. Specifically, HTML files are ignored, like you noted. You can see this by creating a regular vite project and setting the options there.
If you want to fully customize the bundle output, you will need to write a custom plugin, like this one, https://github.com/aklinker1/wxt/blob/main/src/core/vite-plugins/multipageMove.ts, that updates the bundle and moves the files in the output directory.
The second problem is that the build fails with...
This is a bug, I'll fix it.
Summary
Some options defined in
scriptViteConfig
andhtmlViteConfig
, specificallybuild.rollupOptions
, get overwritten byvite-plugin-web-extension
's own options. Additionally, changing filename patterns can make the build fail. This makes setting custom output patterns harder.I would like to customize output patterns for some files. Specifically, to remove
src
prefix from HTML files, to have CSS and JS files in the same directory and the same filename as HTML file, while third-party/vendor/shared files should be in another directory. However, even after settingbuild.rollupOptions.output
insidescriptViteConfig
andhtmlViteConfig
, some patterns are not respected.The file layout that I would like is something like this, in case this is relevant:
It seems (part of the) problem is that user option can get overwritten here and here, possibly also on other places. I don't know if this is intentional, but if it is, I think there should be another way to provide a custom output config.
Reproduction
I have a mostly empty template for Vue with TypeScript, with the following modifications to
vite.config.ts
:All of these options are set just for testing, I haven't yet configured all the patterns that I want. The same problem happens if I only use the root's
build
or only thebuild
defined in the plugin.The first problem is that my custom
fileNames
patterns are not respected for all files (CSS files are still in the root directory):The second problem is that the build fails with:
If I manually edit the plugin's code to remove its
output
definitions, more filename patterns (for CSS files) are respected:But the build still fails.
Environment