{"id":22836,"library":"vite-plugin-sitemap","title":"vite-plugin-sitemap","description":"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.","status":"active","version":"0.8.2","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install vite-plugin-sitemap","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-sitemap","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-sitemap","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency - plugin designed for Vite build tool","package":"vite","optional":false}],"imports":[{"note":"Plugin provides a default export. CommonJS require will not work in ESM-only Vite config.","wrong":"const { Sitemap } = require('vite-plugin-sitemap')","symbol":"default","correct":"import Sitemap from 'vite-plugin-sitemap'"},{"note":"It's a default export, not named. Named import attempt will fail with undefined.","wrong":"import { Sitemap } from 'vite-plugin-sitemap'","symbol":"Sitemap","correct":"import Sitemap from 'vite-plugin-sitemap'"},{"note":"Utility type for per-route configuration. Only needed if using TypeScript.","symbol":"type RoutesOptionMap","correct":"import type { RoutesOptionMap } from 'vite-plugin-sitemap'"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport vue from '@vitejs/plugin-vue';\nimport Sitemap from 'vite-plugin-sitemap';\n\nexport default defineConfig({\n  plugins: [\n    vue(),\n    Sitemap({ hostname: 'https://example.com' })\n  ]\n});","lang":"typescript","description":"Basic Vite config with Vue and sitemap plugin generating sitemap.xml at build time."},"warnings":[{"fix":"Upgrade Vite to version 2 or later.","message":"Plugin requires Vite 2.x or newer. Older Vite 1.x is not supported.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Manually list dynamic routes using `dynamicRoutes` option.","message":"Pages are discovered from the final dist folder. Only routes that produce static HTML files are included; SPA fallback pages may be missed.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `exclude` to filter out non-page files.","message":"The plugin does not support SSR or pre-rendering detection. All discovered files are added, even if they are partial HTML or API responses.","severity":"gotcha","affected_versions":"all"},{"fix":"Remove `outDir` and rely on Vite's default `dist` or set `build.outDir` consistently.","message":"The `outDir` option may conflict with Vite's `build.outDir`. Inconsistent paths can cause missing sitemap.","severity":"deprecated","affected_versions":"<0.7.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `npm install -D vite-plugin-sitemap`.","cause":"Package not installed or missing from node_modules.","error":"ERROR: Cannot find module 'vite-plugin-sitemap'"},{"fix":"Use default import: `import Sitemap from 'vite-plugin-sitemap'`.","cause":"Using named import instead of default import: `import { Sitemap } from 'vite-plugin-sitemap'`.","error":"TypeError: Sitemap is not a function"},{"fix":"Add `dynamicRoutes` array with route paths or ensure your app generates static HTML files (e.g., using SSR or prerendering).","cause":"No static HTML files found in dist folder and no dynamicRoutes provided.","error":"Error: The plugin `vite-plugin-sitemap` requires at least one route. Please provide `dynamicRoutes` or ensure your build outputs HTML files."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}