Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Nuxt Compatibilty 4 Glob error #176

Closed
moshetanzer opened this issue Nov 17, 2024 · 20 comments
Closed

Nuxt Compatibilty 4 Glob error #176

moshetanzer opened this issue Nov 17, 2024 · 20 comments

Comments

@moshetanzer
Copy link

Hi,

Hope you well.

Been getting this on all Nuxt 4 builds. Any clues?

vite-pwa/vite-plugin-pwa#15 149.6 PWA v0.21.0
vite-pwa/vite-plugin-pwa#15 149.6 mode      generateSW
vite-pwa/vite-plugin-pwa#15 149.6 precache  3 entries (0.21 KiB)
vite-pwa/vite-plugin-pwa#15 149.6 files generated
vite-pwa/vite-plugin-pwa#15 149.6   ../.output/public/sw.js
vite-pwa/vite-plugin-pwa#15 149.6   ../.output/public/workbox-4723e66c.js
vite-pwa/vite-plugin-pwa#15 149.6 warnings
vite-pwa/vite-plugin-pwa#15 149.6   One of the glob patterns doesn't match any files. Please remove or fix the following: {
vite-pwa/vite-plugin-pwa#15 149.6   "globDirectory": "/app/.output/public",
vite-pwa/vite-plugin-pwa#15 149.6   "globPattern": "**/_payload.json",
vite-pwa/vite-plugin-pwa#15 149.6   "globIgnores": [
vite-pwa/vite-plugin-pwa#15 149.6     "**/node_modules/**/*",
vite-pwa/vite-plugin-pwa#15 149.6     "sw.js",
vite-pwa/vite-plugin-pwa#15 149.6     "workbox-*.js"
vite-pwa/vite-plugin-pwa#15 149.6   ]
vite-pwa/vite-plugin-pwa#15 149.6 }

@userquin
Copy link
Member

what's your pwa configuration?

@userquin userquin transferred this issue from vite-pwa/vite-plugin-pwa Nov 17, 2024
@moshetanzer
Copy link
Author

Just manifest with icons and short name and name and description.

@userquin
Copy link
Member

userquin commented Nov 17, 2024

Maybe we need to check v4 compat mode and use rootDir instead srcDir, will check it tmr.

Can you check it using create pwa https://vite-pwa-org.netlify.app/guide/scaffolding.html ? Select vue then Nuxt 4 and follow the wizard (update nuxt to latest verrsion 3.14.159 if required)

@moshetanzer
Copy link
Author

Hey @userquin yip! that is the issue! Build fine when using the nuxt 4 compat template!

@moshetanzer
Copy link
Author

@userquin any temp workaround. What can I set the srcdir as?

@userquin
Copy link
Member

userquin commented Nov 18, 2024

try changing workbox.globDirectory to use ./.output/public, the build output folder should be on root.

EDIT: check where is the sw.js, maybe you need to change outDir in pwa options.

@userquin
Copy link
Member

@userquin
Copy link
Member

You need to change both, workbox.globDirectory and outDir: previous module will not configure workbox.globDirectory.

@userquin
Copy link
Member

If you're using SSR (ssr: true or not configured or running nuxt generate ), check also if the sw.js and workbox-**.js present in .output/server folder.

@moshetanzer
Copy link
Author

If you're using SSR (ssr: true or not configured or running nuxt generate ), check also if the sw.js and workbox-**.js present in .output/server folder.

am using ssr, not present in .output/server only in public

@moshetanzer
Copy link
Author

try changing workbox.globDirectory to use ./.output/public, the build output folder should be on root.

EDIT: check where is the sw.js, maybe you need to change outDir in pwa options.

I tried to change both and set with ./.output/public did not work

@userquin
Copy link
Member

userquin commented Nov 18, 2024

Add this in your nuxt config file:

import { createResolver } from '@nuxt/kit' // <== it is @nuxt/kit not @nuxtjs/kit

const { resolve } = createResolver(import.meta.url)

const outDir = resolve('./.output/public')

@moshetanzer
Copy link
Author

that wont work nuxtjs kit is not available in nuxt config if not module

@userquin
Copy link
Member

or

import { fileURLToPath } from 'node:url'
import { resolve } from 'node:path'

const outDir = fileURLToPath(new URL('./.output/public', import.meta.url))

@userquin
Copy link
Member

Use __dirname instead of import.meta.url, you can also add "type": "module", to your package.json

@moshetanzer
Copy link
Author

Nope, sorry - none of this works. of course type is set to module - but nuxt kit is only availble as far as i understand in an actula nuxt module context?

@danielroe any simple workaround for the moment? I see you did the nuxt 4 compat version for the scaffold cli

@userquin
Copy link
Member

If repo created using create-pwa works, why your repository is not working? Did you follow the instructions in nuxt docs https://nuxt.com/docs/getting-started/upgrade#new-directory-structure (check Migration Steps a few line below)?

@moshetanzer
Copy link
Author

Hey. Of course have quite a few projects running on v4 compact for about 3 months already!

I think that the specific nuxt module is not compatible with v4 yet. Even though when scaffolding it is since it isn't using the same module?

@userquin
Copy link
Member

🙏 provide a minimal reproduction with your issue, I will check what's happening...

@moshetanzer
Copy link
Author

seems like this was a cache issue was using experimntal build cache on swapover from Nuxt 3 to 4 - which for some reason even after setting to false was persisting in production - this is not a bug as far as i can tell.

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

No branches or pull requests

2 participants