Closed aplauche closed 1 year ago
Update - tried using vite-plugin-static-copy, but this also does not work since it copies the sitemap into the final _site folder before vite attempts to generate all the other files. This causes an error.
I've just encountered this with a robots.txt file. Change your permalink to /public/sitemap.xml
and it should be copied to production.
This is intended behaviour since Vite only copies files that are referenced in the website's source code, whereas those files are not. I think it works in the dev server as Vite works in-place there and the original files aren't discarded.
Ah interesting that makes sense. Thanks for sharing your fix. I'll go ahead and close this - hopefully will be helpful to others in the future though as well.
Using this plugin on a basic site, but a big issue is when creating a sitemap using a sitemap.njk file with the following code:
The sitemap is generated in dev server mode, but when built it is created in the .11ty-vite folder, but vite ignores it and it is not copied into the production build. Looking into vite options to fix this, but figured I would log as an issue as well since this likely is affecting other users too and is a bit tricky to notice since it seems to work fine on dev and does not throw any notices or errors.