Registry / devops / vite-ssg-sitemap

vite-ssg-sitemap

JSON →
library0.10.0jsnpmunverified

A sitemap generator plugin for Vite projects using vite-ssg, built on top of sitemap-ts. Version 0.10.0, actively maintained. It automates sitemap.xml and robots.txt generation during static site builds. Key differentiators: tight integration with vite-ssg's lifecycle (onFinished hook), supports dynamic routes, route-level overrides for change frequency/priority/lastmod, i18n alternate links, and customizable output options. Simpler than full-featured sitemap libraries but specifically designed for the vite-ssg ecosystem.

npm install vite-ssg-sitemap
INSTALL
IMPORT
SIG · VITE-SSG-SITEMAP
V
vite-ssg-sitemap
devopsjavascriptv0.10.0
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.

generateSitemap
import generateSitemap from 'vite-ssg-sitemap'
import { generateSitemap } from 'vite-ssg-sitemap'
Default export only. Named import will result in undefined.
generateSitemap
const generateSitemap = require('vite-ssg-sitemap')
const { generateSitemap } = require('vite-ssg-sitemap')
CJS require returns default as module.exports. Destructuring fails.
generateSitemap type
import type { RouteOptionMap, SitemapOption } from 'vite-ssg-sitemap'
import { RouteOptionMap } from 'vite-ssg-sitemap'
Types are not runtime values; use type import for TypeScript.

Example of using generateSitemap in vite.config.ts with i18n, dynamic routes, exclusions, and readable XML.

// vite.config.ts import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import generateSitemap from 'vite-ssg-sitemap' export default defineConfig({ plugins: [vue()], ssgOptions: { onFinished() { generateSitemap({ hostname: 'https://example.com', dynamicRoutes: ['/about', '/contact'], exclude: ['/admin'], readable: true, i18n: { defaultLanguage: 'en', languages: ['fr', 'de'], strategy: 'prefix' } }) } } })
Debug
Known issues
gotchagenerateSitemap is a default export, not a named export. Importing with destructured { generateSitemap } yields undefined.
fix
Use `import generateSitemap from 'vite-ssg-sitemap'` (no braces).
affects: >=0.0.0
gotchaThe `hostname` option defaults to 'http://localhost/', which may produce invalid sitemap URLs in production. Always set a proper hostname.
fix
Pass `hostname: 'https://yoursite.com'` in options.
affects: >=0.0.0
breakingIn v0.6.0, the `i18n` option was refactored. The `defaultLanguage` property was added and `languages` is now required if using i18n. Old `lang` property removed.
fix
Update your i18n config to { defaultLanguage?, languages: string[] }.
affects: <0.6.0
gotchaThe `outDir` is relative to the project root, not the Vite build output config. If you customize Vite's build.outDir, you must set this option accordingly.
fix
Set `outDir` to match your Vite build output directory (default 'dist').
affects: >=0.0.0
deprecatedVersion 0.6.0 removed automatic route detection from vite-ssg. You must now pass routes via `dynamicRoutes`; the plugin no longer reads the vue-router routes.
fix
Manually collect routes and pass to `dynamicRoutes`. See README for example.
affects: >=0.6.0
Errors
Common errors & fixes
TypeError: generateSitemap is not a function
Importing with named import instead of default import.
fix
Use `import generateSitemap from 'vite-ssg-sitemap'` (default import).
Error: No routes provided: sitemap will be empty
No `dynamicRoutes` passed and no automatic route detection (since v0.6.0).
fix
Pass an array of route paths to `dynamicRoutes` in options.
Error: Cannot find module 'sitemap-ts'
Missing peer dependency sitemap-ts.
fix
Run `npm install -D sitemap-ts`.
Error: XML parsing failed: Invalid tag name at line X
Route path contains invalid characters (e.g., spaces, reserved XML characters).
fix
Ensure all route strings are URL-encoded or sanitized.
Upgrade
Version history
0.10.0latest on npm
Audit
Dependencies
sitemap-tsrequiredCore dependency for sitemap XML generation and validation
vite-ssgrequiredPeer dependency; integrates as a build lifecycle hook
Agent activity
4 hits · last 30 days
node
4
Resources
vite-ssg-sitemap — npm install vite-ssg-sitemap · libregistry