Registry / devops / vite-plugin-sitemap

vite-plugin-sitemap

JSON →
library0.8.2jsnpmunverified

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-sitemap
INSTALL
IMPORT
SIG · VITE-PLUGIN-SITEMA
V
vite-plugin-sitemap
devopsjavascriptv0.8.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import Sitemap from 'vite-plugin-sitemap'
const { Sitemap } = require('vite-plugin-sitemap')
Plugin provides a default export. CommonJS require will not work in ESM-only Vite config.
Sitemap
import Sitemap from 'vite-plugin-sitemap'
import { Sitemap } from 'vite-plugin-sitemap'
It's a default export, not named. Named import attempt will fail with undefined.
type RoutesOptionMap
import type { RoutesOptionMap } from 'vite-plugin-sitemap'
Utility type for per-route configuration. Only needed if using TypeScript.

Basic Vite config with Vue and sitemap plugin generating sitemap.xml at build time.

import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; import Sitemap from 'vite-plugin-sitemap'; export default defineConfig({ plugins: [ vue(), Sitemap({ hostname: 'https://example.com' }) ] });
Debug
Known issues
breakingPlugin requires Vite 2.x or newer. Older Vite 1.x is not supported.
fix
Upgrade Vite to version 2 or later.
affects: >=0.1.0
gotchaPages are discovered from the final dist folder. Only routes that produce static HTML files are included; SPA fallback pages may be missed.
fix
Manually list dynamic routes using `dynamicRoutes` option.
affects: all
gotchaThe plugin does not support SSR or pre-rendering detection. All discovered files are added, even if they are partial HTML or API responses.
fix
Use `exclude` to filter out non-page files.
affects: all
deprecatedThe `outDir` option may conflict with Vite's `build.outDir`. Inconsistent paths can cause missing sitemap.
fix
Remove `outDir` and rely on Vite's default `dist` or set `build.outDir` consistently.
affects: <0.7.0
Errors
Common errors & fixes
ERROR: Cannot find module 'vite-plugin-sitemap'
Package not installed or missing from node_modules.
fix
Run `npm install -D vite-plugin-sitemap`.
TypeError: Sitemap is not a function
Using named import instead of default import: `import { Sitemap } from 'vite-plugin-sitemap'`.
fix
Use default import: `import Sitemap from 'vite-plugin-sitemap'`.
Error: The plugin `vite-plugin-sitemap` requires at least one route. Please provide `dynamicRoutes` or ensure your build outputs HTML files.
No static HTML files found in dist folder and no dynamicRoutes provided.
fix
Add `dynamicRoutes` array with route paths or ensure your app generates static HTML files (e.g., using SSR or prerendering).
Upgrade
Version history
0.8.2latest on npm
Audit
Dependencies
viterequiredpeer dependency - plugin designed for Vite build tool
Agent activity
4 hits · last 30 days
node
4
Resources
vite-plugin-sitemap — npm install vite-plugin-sitemap · libregistry