Giter Club home page Giter Club logo

Comments (4)

danieldanielecki avatar danieldanielecki commented on June 9, 2024

Most of my PWA-related changes/fixes/debugging were in: Doyban/Doyban-Website@6c13721 whereas the entire repo can be found on https://github.com/Doyban/Doyban-Website

from nuxt.

userquin avatar userquin commented on June 9, 2024

why are you using injectManifest strategy without a custom sw? Use generateSW strategy (default), it should work.

EDIT: are you using generate or build to deploy the app? if using build, you should prerender the root route (/)

from nuxt.

danieldanielecki avatar danieldanielecki commented on June 9, 2024

No changes without injectManifest / with generateSW.
I have ServiceWorker in public/sw.js:

import { clientsClaim } from 'workbox-core'
import {
  precacheAndRoute,
  cleanupOutdatedCaches,
  createHandlerBoundToURL,
} from 'workbox-precaching'
import { registerRoute, NavigationRoute } from 'workbox-routing'

self.skipWaiting()
clientsClaim()
precacheAndRoute(self.__WB_MANIFEST)
cleanupOutdatedCaches()

//You can remove this code if you aren't precaching anything, or leave it in and live with the warning message
try {
  const handler = createHandlerBoundToURL('/')
  const route = new NavigationRoute(handler)
  registerRoute(route)
} catch (error) {
  console.warn('Error while registering cache route', { error })
}

I'm using generate.

from nuxt.

userquin avatar userquin commented on June 9, 2024

Move the sw.js to some src folder and update the pwa options, you need to "build" it since cannot use you're using import statements inside a service worker (sw cannot use static/dynamic imports if you don't register it using type module, and will work only on chromium based browsers; IIRC you cannot use dynamic imports with type module yet).

You can also change static imports with importScripts but you will need to add them also to the public folder or use CDN (you can keep your service worker in the public folder).

Check elk.zone github repo, you've an example and the configuration needed to build your service worker, check servce-worker folder and typescrupt option in nuxt.config.ts file (the service worker using TypeScript):

from nuxt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.