sapper icon indicating copy to clipboard operation
sapper copied to clipboard

sapper incremental export - can export update only one route, not all the contents of site?

Open NadiaRom opened this issue 5 years ago • 7 comments

In case of blog or news website we need to update collections of dynamic routes, but not to render each item on update as sapper export command does .

Is there a way to export just one route, not the whole site? similar to https://nuxtjs.org/api/nuxt-render-route.

The ideal workflow is:

  1. server receives a webhook - for example, a new article is added
  2. and triggers rendering of routes/articles/fresh-article-slug, then adds it to thousands of previously generated articles as __sapper__/export/articles/fresh-article-slug without affecting the rest.

Can I do it with Sapper?

As of now, the only solution I see is to have a temporary export destination, where to put only the updated article. Next dully copy the exported updated one to its fellows in a real export folder. Definetly this solution is terrible. How to do a proper update of static website (if possible)?

NadiaRom avatar Mar 08 '19 23:03 NadiaRom

I think Sapper currently uses timestamps in filenames. That makes incremental builds challenging.

thgh avatar Mar 09 '19 08:03 thgh

Thank you! I see... After looking at Gatsby and Gridsome it is surprising that so few static site generators support incremental builds.

I would appreciate any comments on the idea to copy&past one exported item from "temporary" export folder to a "general" export folder. May it work around the problem?

NadiaRom avatar Mar 09 '19 14:03 NadiaRom

This is a great idea to consider, especially for larger projects that take a while to export.

s0kil avatar May 19 '19 01:05 s0kil

Where do timestamps come in during the build?

I feel like this would be as easy as sapper export --entry /url/to/updated/route --no-crawl with the idea only that entry point would be crawled, but the code to go to multiple links would not run.

Maybe I am over simplifying this?

It appears that during export hashes are no longer added based on #670 - is that right @Conduitry .

khrome83 avatar Aug 19 '19 15:08 khrome83

@NadiaRom @s0kil - we added #856 to allow building a single page. We will be opening a PR soon for filtering routes as well. This PR will only do the entry point. The next one will do routes that match a regex condition allow you to split your builds.

khrome83 avatar Aug 22 '19 20:08 khrome83

@Conduitry - I'm wondering if there's any updates on this?

My use case is that I want to generate a single page only export, but let the rest be. My sitemap on my site is now into the ~35k+ links and has to make API requests to generate. I'd like that to generate once /day or on deploy, or whatever.

I was hoping I could just do

npx sapper export --entry "sitemap"               

which would call my sitemap and generate it. However, it generates the entire site, which is unnecessary as it's stateful and is rendered by express.

I wasn't able to find a way to generate a singular page, and it looks like this was the closest idea to doing that.

Thanks!

davidwparker avatar Feb 27 '21 19:02 davidwparker