Giter Club home page Giter Club logo

Comments (5)

userquin avatar userquin commented on May 30, 2024

@AKuederle try to configure scope pwa option with the base path configured in kit config.

from sveltekit.

AKuederle avatar AKuederle commented on May 30, 2024

Thank you very much for the fast response. The scope option didn't help, but setting the base option in the SvelteKitPWA plugin seems to solve the above issue. This way the manifest and the assets seemed to be served correctly.

For some reason I thought, that the default for this setting (vite.base) would have been already set by sveltekit itself. But it seems not to be the case.

However, even with these settings, offline access does not seem to work. This seems to be independent of the base-path though. So it is likely a different issue. But basically it seems like the service worker caches everything BUT the actual index.html file generated during build does not seem to be cached by the service worker, resulting in non-prechached-url error on a repeated app load.

from sveltekit.

AKuederle avatar AKuederle commented on May 30, 2024

Ok I solved the issue! But maybe this is interesting for others:

I forgot to mark my page as prerenderable, (export const prerender = true in +layout.ts) and instead set a fallback page in the adapter static configuration. This allows the static build to succeed, but because the page is not marked as prerenderable, it is not added to the service worker cache.

I don't know if this is the intended interaction, but making sure to mark all my pages to be pre-rendered solved my issue.

@userquin Do you think this is something worth adding to the documentation somewhere? I am happy to contribute a paragraph.

from sveltekit.

userquin avatar userquin commented on May 30, 2024

@AKuederle you can send a PR to docs repo, to use precaching we need at least 1 html page, so you need at least 1 page with prerender = true: check this PR as an example to use PWA plugin without precaching (not kit releated)

On kit, if you're not using precaching, you can use kit service worker implementation instead using this integration.

from sveltekit.

drewbitt avatar drewbitt commented on May 30, 2024

@userquin This 100% should be in docs. I just set it up with "Zero Config", no SvelteKitPWA() settings, which does not work; it shows a warning when no document is prerendered e.g.

warnings
  One of the glob patterns doesn't match any files. Please remove or fix the following: {
  "globDirectory": "C:/Users/andys-pc/GitHub/MyStuff/Someplice/.svelte-kit/output",
  "globPattern": "prerendered/**/*.html",
  "globIgnores": [
    "**/node_modules/**/*",
    "server/sw.js",
    "server/workbox-*.js"
  ]
}

but it is not documented that this is required. And in fact in my simple Sveltekit app, even prerendering a page my PWA does not show up in browser. The requirement of a service worker config and/or vite.base and/or prerender is not obvious... docs make this seem like zero-config should work.

from sveltekit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.