Skip to content

injectRegister: false still registers service worker #186

Open
@liamb0t

Description

@liamb0t

I'm trying to register my service worker manually so that it only gets registered when visiting specific URLs in my app. I've set injectRegister: false thinking it would not register the SW. But even so, and even if I don't install it manually, I can still see the service working being registered and pre-caching data in the dev tools?? How can I register it manually?

This is the current config:

pwa: {
    scope: '/',
    base: '/',
    manifest: false,
    injectRegister: false,
    registerType: 'prompt',
    workbox: {
      globPatterns: ['**/*.{js,css,html,png,svg,ico}'],
      runtimeCaching: [
        {
          urlPattern: ({ url }) => url.origin === 'https://myapp.directus.app',
          handler: 'NetworkFirst',
          options: {
            cacheName: 'directus-cache'
          }
        },
        {
          urlPattern: ({ request }) => request.destination === 'video',
          handler: 'CacheFirst',
          options: {
            cacheName: 'video-cache'
          }
        }
      ],
      navigateFallback: undefined,
      maximumFileSizeToCacheInBytes: 50 * 1024 * 1024 // 50MB,
    }
  },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions