mates-ssg
v1.3.1
Published
Prerender any SPA dist into static HTML + sitemap/robots for CDN hosting
Maintainers
Readme
mates-ssg
Zero-config SPA → static HTML for Netlify / Cloudflare / S3 / any CDN.
Install as a dev dependency:
npm i -D mates-ssg
npx mates-ssg buildWhat it does
- Builds your SPA (
npm run build/ pnpm / yarn / bun) - Serves
dist/on localhost (CI-safe — notvite preview) - Opens one headless Chrome with many concurrent tabs
- Crawls same-origin
<a href>, writesroute/index.html, grows the route set - Writes
sitemap.xml,robots.txt,_redirects, and keeps__spa__.htmlfor CDN fallback
Zero-config defaults
| Setting | Auto |
|---------|------|
| SPA build | npm/pnpm/yarn/bun run build |
| outDir | dist, build, or out (first with index.html) |
| routes | Start at /, harvest <a href> while prerendering |
| browser | Headless Chrome (Puppeteer) |
| concurrency | 2× CPU cores (clamped 8–24 tabs in one Chrome) |
| siteUrl | SITE_URL / URL env, or package.json "homepage" |
Speed
mates-ssg build --concurrency 16All tabs share one Chrome process and one in-memory crawl queue (queued / visited), so links discovered by any tab are scheduled exactly once.
Skip links (nofollow / data-no-ssg)
Anchors are not enqueued for prerender/sitemap when:
<a href="/admin" rel="nofollow">Admin</a>
<a href="/draft" data-no-ssg>Draft</a>
<a href="/x" rel="noopener nofollow">X</a>Use these for links you do not want static HTML for. Prefer data-no-ssg when you only want to affect mates-ssg (not search-engine nofollow semantics).
Optional overrides
mates-ssg build --site-url https://example.com
mates-ssg build -r routes.json # fixed list (optional crawl)
mates-ssg build --concurrency 20package.json
{
"homepage": "https://example.com",
"scripts": {
"ssg": "mates-ssg build"
},
"devDependencies": {
"mates-ssg": "^1.3.0"
}
}