sveltesapper

Failing to generate dynamic routes with Sapper export


I have a dynamic route:

routes/artwork/[slug].svelte.

All works great with npm run dev.

But when I npm run export those dynamic slug routes are missing. I don't see them in the __sapper__/export, and the pages are missing as well when I uploaded to Netlify.

Any clue how I might be able to fix that? Did I miss something obvious?


Solution

  • sapper export works by building your app, running it, then visiting / and recursively visiting every internal link it finds. For that reason, it has to be possible to get to /artwork/foo and /artwork/bar etc by following links from the home page (e.g. via a routes/artwork/index.svelte page, which would map to /artwork).