vite-pwa / sveltekit

Zero-config PWA Plugin for SvelteKit
https://vite-pwa-org.netlify.app/frameworks/sveltekit
MIT License
324 stars 15 forks source link

Can't get @vite-pwa/sveltekit to work out-of-the-box #49

Closed Nickersoft closed 1 year ago

Nickersoft commented 1 year ago

Hey folks,

After reading the docs over and over, I can't for the life of me figure out why I'm having so much trouble building my project with @vite-pwa/sveltekit. I based most of my implementation off of this repo, which successfully uses the plugin, yet when I try to build I receive:

warnings
  One of the glob patterns doesn't match any files. Please remove or fix the following: {
  "globDirectory": "/Users/tjnickerson/Documents/GitHub/Nickersoft/vite-pwa-repro/.svelte-kit/output",
  "globPattern": "client/**/*.{js,css,ico,png,svg,webp,webmanifest}",
  "globIgnores": [
    "**/node_modules/**/*",
    "server/sw.js",
    "server/workbox-*.js"
  ]
}
  One of the glob patterns doesn't match any files. Please remove or fix the following: {
  "globDirectory": "/Users/tjnickerson/Documents/GitHub/Nickersoft/vite-pwa-repro/.svelte-kit/output",
  "globPattern": "prerendered/**/*.html",
  "globIgnores": [
    "**/node_modules/**/*",
    "server/sw.js",
    "server/workbox-*.js"
  ]
}

[vite-plugin-pwa:sveltekit:build] ENOENT: no such file or directory, open '/Users/tjnickerson/Documents/GitHub/Nickersoft/vite-pwa-repro/.svelte-kit/output/client/sw.js'
error during build:
Error: ENOENT: no such file or directory, open '/Users/tjnickerson/Documents/GitHub/Nickersoft/vite-pwa-repro/.svelte-kit/output/client/sw.js'
 ELIFECYCLE  Command failed with exit code 1.

Removing the custom code I have in +layout.svelte seems to fix the build, even though the code I put in there is verbatim from the docs. The reason the plugin can't find the above file is because sw.js instead lives in .svelte-kit/server, not client.

My reproduction repo is here. You just run pnpm install and then pnpm build. Any pointers would be appreciated.

userquin commented 1 year ago

@Nickersoft using Node 18 with linked repo:

imagen

userquin commented 1 year ago

and the preview in oflline mode:

imagen

userquin commented 1 year ago

try removing node_modules and reinstalling dependencies

Nickersoft commented 1 year ago

My apologies, my reproduction is linked at the bottom of the issue. The site you just ran is the example repo I gave that seems to be working, despite having the same setup as my failing reproduction. I've tried wiping node_modules, but to no avail.

userquin commented 1 year ago

ok, I'll check it later...

userquin commented 1 year ago

@Nickersoft found the problem, we need to create the .svelte-kit/output/client folder, since the kit pwa plugin runs after prerender but before adapter processes, that folder is not there on first build.

Can you just create client folder and test again? I'll send a fix ASAP.

EDIT: the folder is recreated every time we run build and so will not work

Nickersoft commented 1 year ago

Thanks for looking into this @userquin! Interesting... any idea why it works for the first repo I linked, but not for my reproduction?

userquin commented 1 year ago

Using another previous kit version, iirc 1.5.0

Nickersoft commented 1 year ago

Huh... could have sworn I tried 1.5.0 and it still failed. Maybe it was using a version range I wasn't aware of.

userquin commented 1 year ago

@Nickersoft can you try adding some pwa manifest icons?

Nickersoft commented 1 year ago

I copied the exact manifest from WhatSend (that contains manifest icons), as well as its assets (in ./src/assets), and am still receiving the same error

userquin commented 1 year ago

@Nickersoft can you test with latest release v0.2.2?

Nickersoft commented 1 year ago

Whoops, just saw this – seems to be building now, thanks!

leovoon commented 1 year ago
  .svelte-kit/output/server/sw.js
  .svelte-kit/output/server/workbox-fc5f5acf.js
warnings
  One of the glob patterns doesn't match any files. Please remove or fix the following: {
  "globDirectory": "/home/msi/tatan/.svelte-kit/output",
  "globPattern": "prerendered/**/*.html",
  "globIgnores": [
    "server/*.*",
    "server/sw.js",
    "server/workbox-*.js"
  ]
}

I got this when no routes are prerendered.