This repository highlights an issue combining next-sitemap with next export when hosting on a static host.
See the thread which prompted this repo
Setup
[email protected], outputs its sitemap to the public directory.
I followed the next documentation for export and have set my npm build script to next build && next export.
and I followed the next-sitemap documentation instructing me to define a postbuild npm command to trigger the sitemap building.
Problem
The problem arises because the npm build command runs next export which would copy the sitemap into out, but the sitemap isn't there yet as it is only created "postbuild".
Solution
The solution is to set the outDir configuration property in sitemap.config.js to out, which is where next export puts its content.
Alternatively, rename postbuild to generate-sitemap and update the npm build command to next build && npm run generate-sitemap && next export.