Closed dasplan closed 2 years ago
Was running into the same problem and can confirm, this fixes the problem! Looking forward to get this merged.
Same here! This works for me as well, but I also had to change the permalink in the front matter for the feed.xml, for example, to
permalink: /public/feed.xml
so that it lands in the /public
folder, which Vite/Rollup then copies to the root of outDir
again.
The name of this public
folder for static assets can be set in Vite via the publicDir
option. So maybe this could be used instead of writing "public" in the code?
@KiwiKilian FYI, I just managed to solve this issue (Rollup breaks on .xml and .txt files) in another way: I included the following line in the viteOptions in .eleventy.js
assetsInclude: ['**/*.xml','**/*.txt'],
This will tell Vite to treat those files as static assets. See: https://vitejs.dev/config/#assetsinclude Works for me locally and with a Netlify build.
++EDIT++ It works insofar as the build runs without errors. But there are still empty JavaScript bundles being generates for files like robots.txt and feed.xml. So your PR still makes a lot of sense IMO!
I will merge this as-is but I think I’ll make some post-merge changes to use the publicDir
option (if changed by vite config)
Thank you!
Shipped with 1.0.0-canary.2
This behavior is going to change slightly with #9!
I was tinkering with this plugin and came across issues with a generated sitemap.xml and robots.txt. When building, rollup breaks on sitemap.xml. If I leave out the sitemap and just build with robots.txt then an empty javascript bundle is created for robots.txt and robots.txt itself is gone. To fix this mattrossman suggested outputting these files to OUTDIR/public and that fixes the robots.txt issue, but rollup still breaks on sitemap.xml. These files should not be passed on to rollup. So, an extra filter is needed to prevent files in OUTDIR/public to be passed to viteOptions.build.rollupOptions.input.
Disclaimer: first time I do a pull request and a bit tired :) Much love for 11ty!