Closed Rhilip closed 2 years ago
Sorry, just saw this!
TBH, I completely forgot about the public folder, thanks for reporting this! I'm surprised it doesn't just work out of the box, I don't think the extension does anything that would effect it. I'll check this out this weekend, and hopefully get out a fix.
If you need something right now, you can use rollup-plugin-copy
to copy files to exactly where they need to go in your output. I use it and it works for both regular and watch build modes.
Sorry for the late reply, it's working fine now
Chrome extension may have some special file ( or folder ) in extension root, like
_locales
folder for i18n, or staticassets
folder. However, After add this vite plugin, those files inpublic
folder will not copy todist
folder when executevite build --watch
. But when execute commandvite build
without--watch
param, those files will copy fined.Steps to reproduce
In this step, we can see the file
test.txt
corrent copy to the public folder, then exit and rm the dist folder.and sort project like the demo/vanilla, the whole filetree are like this
in manifest.json, I change the key
name
like:and the minimal reproduction can see this repo: https://github.com/Rhilip/bugreport-vite-plugin-web-extension-watchbuild
The run the build command,
vite build --watch
, the dist folder is likevite build
, the dist folder is likeI also test two structure, however still same as step 3
_locales
folder inside src folder, and use same assets folder.What is actually happening?
When run command
vite build
, the files in public folder will be copy todist/background
folder anddist
folder, When run commandvite build --watch
, those files will only be copy todist/background
folder.What is expected?
When run command
vite build
orvite build -watch
, the public folder will copy as default vite behavior: copy todist
folder.