Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Having an issue with ssr = false #52

Closed
hamishjohnson opened this issue May 13, 2023 · 8 comments
Closed

Having an issue with ssr = false #52

hamishjohnson opened this issue May 13, 2023 · 8 comments

Comments

@hamishjohnson
Copy link

I'm trying to get this package working with a SPA with export const ssr = false; but it doesn't seem to be working when deployed. It works fine in dev mode.

I get this error

workbox-3625d7b0.js:1 Uncaught (in promise) non-precached-url: non-precached-url :: [{"url":"/"}]
    at O.createHandlerBoundToURL (https://test-sveltkit-gfjc7ulcj-hamishjohnson.vercel.app/workbox-3625d7b0.js:1:13245)
    at Object.createHandlerBoundToURL (https://test-sveltkit-gfjc7ulcj-hamishjohnson.vercel.app/workbox-3625d7b0.js:1:14916)
    at https://test-sveltkit-gfjc7ulcj-hamishjohnson.vercel.app/sw.js:1:3190

And so I tried prerendering the homepage but kept getting further precache issues

Here's an example repo https://github.com/hamishjohnson/test-sveltkit-pwa

And here it is deployed: https://test-sveltkit-gfjc7ulcj-hamishjohnson.vercel.app/ with errors in console

@userquin
Copy link
Member

@hamishjohnson if you're using precaching you need 1 route as fallback, by default is the entry point: you need to prerender 1 route

@userquin
Copy link
Member

it seems kit 1.5.0 has some problems with SSR builds, if you check the sw it includes server assets... can you try updating to latest version?

Tried with adapter node and same result...

@hamishjohnson
Copy link
Author

Yeah I tried it with prerendering the root page in +page.ts.

And I just tried in both 1.16.3 and 1.14 but I'm experiencing the same problem. In each version when running build the server files get included which also confused me but that seems to have always been the case as seen here sveltejs/kit#9161

@userquin
Copy link
Member

@hamishjohnson you can solve server assets including globIgnores:

      workbox: {
        globPatterns: ["client/**/*.{js,css,html,ico,png,svg}"],
        globIgnores: ["server/*.*"] // <== to remove server entries from sw precache manifest
      },

Since you're using auto adapter, there is no way to copy prerendered/pages/index.html to the output folder: you must copy it manually, the navigateFallback is properly added to sw precache manifest (just check .sveltekit/output/client/ folder).

Using node adapter also works, the output folder will be build, but same problem with prerendered page.

@userquin
Copy link
Member

uhmm, node adapter should work, I'll test it later:

imagen

@userquin
Copy link
Member

userquin commented May 14, 2023

it works, running yarn preview after changing to node adapter and building the app:

imagen

@hamishjohnson
Copy link
Author

Ah :) The glob ignore worked for me, so I didn't try the Node Adapter, though I did try that before. Thanks for your help! I guess it should be documented.

@userquin
Copy link
Member

@hamishjohnson should be fixed in v0.2.2: server/*.* included in globIgnores if not configured.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants