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

Nuxt3 + PWA warnings in terminal #127

Open
Krystus opened this issue Apr 4, 2024 · 6 comments
Open

Nuxt3 + PWA warnings in terminal #127

Krystus opened this issue Apr 4, 2024 · 6 comments

Comments

@Krystus
Copy link

Krystus commented Apr 4, 2024

Is it normal that after PWA implementation in terminal I see warnings like that?

WARN warnings 6:49:09 PM
One of the glob patterns doesn't match any files. Please remove or fix the following: {
"globDirectory": "/Users/x/Vue/xx/.nuxt/dev-sw-dist",
"globPattern": "/*.{json,ico,svg,ttf,woff,css,scss,js,html,txt,jpg,png,woff2,mjs,otf,ani}",
"globIgnores": [
"
/node_modules//",
"sw.js",
"workbox-
.js"
]
}
One of the glob patterns doesn't match any files. Please remove or fix the following: {
"globDirectory": "/Users/x/Vue/xx/.nuxt/dev-sw-dist",
"globPattern": "_nuxt/builds/
/.json",
"globIgnores": [
"/node_modules//
",
"sw.js",
"workbox-*.js"
]
}

WARN [Vue Router warn]: No match found for location with path "/sw.js.map"

WARN [Vue Router warn]: No match found for location with path "/sw.js.map"

WARN [Vue Router warn]: No match found for location with path "/sw.js.map"

WARN [Vue Router warn]: No match found for location with path "/sw.js.map"

WARN [Vue Router warn]: No match found for location with path "/workbox-63ce180e.js.map"

WARN [Vue Router warn]: No match found for location with path "/workbox-63ce180e.js.map"

WARN [Vue Router warn]: No match found for location with path "/workbox-63ce180e.js.map"

WARN [Vue Router warn]: No match found for location with path "/workbox-63ce180e.js.map"

@mojjjtaba
Copy link

I got the same error

@userquin
Copy link
Member

About workbox warnings, check https://vite-pwa-org.netlify.app/guide/faq.html#suppress-workbox-build-warnings-in-dev

About router warnings, try update to latest nuxt 3.11.2

@ivanushkaPr
Copy link

ivanushkaPr commented May 17, 2024

Same here.

PWA v0.20.0
mode generateSW
precache 1 entries (0.00 KiB)
files generated
.nuxt/dev-sw-dist/sw.js.map
.nuxt/dev-sw-dist/sw.js
.nuxt/dev-sw-dist/workbox-9637eeee.js.map
.nuxt/dev-sw-dist/workbox-9637eeee.js

WARN warnings
One of the glob patterns doesn't match any files. Please remove or fix the following: {
"globDirectory": "/app/.nuxt/dev-sw-dist",
"globPattern": "_nuxt/builds//*.json",
"globIgnores": [
"
/node_modules/**/",
"sw.js",
"workbox-
.js"
]
}

@RomanKollerSnoop
Copy link

Check if adding this will fix your issue:

pwa: {
workbox: {
globPatterns: ['**/*.{js,css,html,png,svg,ico}'],
},
},

@ivanushkaPr
Copy link

Check if adding this will fix your issue:

pwa: { workbox: { globPatterns: ['**/*.{js,css,html,png,svg,ico}'], }, },

That doesnt change anything.

@RomanKollerSnoop
Copy link

RomanKollerSnoop commented May 21, 2024

Check if adding this will fix your issue:
pwa: { workbox: { globPatterns: ['**/*.{js,css,html,png,svg,ico}'], }, },

That doesnt change anything.

The issue was gone for me when i set it up like this.
This is my full config:
`
const sw = process.env.SW === 'true'

pwa: {
    strategies: sw ? 'injectManifest' : 'generateSW',
    srcDir: sw ? 'public' : undefined,
    filename: sw ? 'sw.ts' : undefined,
    registerType: 'autoUpdate',
    pwaAssets: {
        config: true,
    },
    workbox: {
        globPatterns: ['**/*.{js,css,html,png,svg,ico}'],
    },
    injectManifest: {
        globPatterns: ['**/*.{js,css,html,png,svg,ico}'],
    },
    client: {
        installPrompt: true,
        periodicSyncForUpdates: 3600,
    },
    devOptions: {
        enabled: true,
        suppressWarnings: true,
        navigateFallback: '/',
        navigateFallbackAllowlist: [/^\/$/],
    },
    manifest: {

...
},
},
`

And the service worker "sw.ts" in the public folder like this:

/// <reference lib="WebWorker" />
/// <reference types="vite/client" />
import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching'
import { clientsClaim } from 'workbox-core'
import { NavigationRoute, registerRoute } from 'workbox-routing'


// eslint-disable-next-line no-undef
declare let self: ServiceWorkerGlobalScope

// self.__WB_MANIFEST is default injection point
precacheAndRoute(self.__WB_MANIFEST)

// clean old assets
cleanupOutdatedCaches()

let allowlist: RegExp[] | undefined
if (import.meta.env.DEV) {
    allowlist = [/^\/$/]
}

// to allow work offline
registerRoute(new NavigationRoute(
    createHandlerBoundToURL('/'),
    { allowlist },
))

self.skipWaiting()
clientsClaim()

Note that i use pwaAssets. So you might need to remove that line or install it if u need.

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

5 participants