nuxt icon indicating copy to clipboard operation
nuxt copied to clipboard

Nuxt3 + PWA warnings in terminal

Open Krystus opened this issue 10 months ago • 6 comments

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"

Krystus avatar Apr 04 '24 16:04 Krystus

I got the same error

mojjjtaba avatar Apr 25 '24 12:04 mojjjtaba

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

userquin avatar Apr 25 '24 12:04 userquin

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" ] }

ivanushkaPr avatar May 17 '24 11:05 ivanushkaPr

Check if adding this will fix your issue:

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

RomanKollerSnoop avatar May 17 '24 15:05 RomanKollerSnoop

Check if adding this will fix your issue:

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

That doesnt change anything.

ivanushkaPr avatar May 20 '24 09:05 ivanushkaPr

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.

RomanKollerSnoop avatar May 21 '24 07:05 RomanKollerSnoop