Generate sitemap.xml and robots.txt automatically when building with Vite. v0.8.2 scans the dist folder after build to discover pages, supports dynamic routes, exclusion patterns, external sitemaps, i18n with alternate hreflang links, and per-route changefreq/priority/lastmod. Ships TypeScript types. Minimal configuration: just provide a hostname. Alternative to vite-plugin-pages for sitemap-only needs.
npm install vite-plugin-sitemapVerified import paths — ran on the pinned version, not inferred.
Basic Vite config with Vue and sitemap plugin generating sitemap.xml at build time.
Upgrade Vite to version 2 or later.
Manually list dynamic routes using `dynamicRoutes` option.
Use `exclude` to filter out non-page files.
Remove `outDir` and rely on Vite's default `dist` or set `build.outDir` consistently.
Run `npm install -D vite-plugin-sitemap`.
Use default import: `import Sitemap from 'vite-plugin-sitemap'`.
Add `dynamicRoutes` array with route paths or ensure your app generates static HTML files (e.g., using SSR or prerendering).