Giter VIP home page Giter VIP logo

Comments (8)

cawa-93 avatar cawa-93 commented on July 18, 2024 1

I was confused that the default strategy was generateSW and my little custom script for was included as workbox.importScripts. It seems that I will have to change the strategy to injectManifest and somehow write the worker myself

from nuxt.

userquin avatar userquin commented on July 18, 2024

@cawa-93 have you tried to import useRuntimeConfig from #app or #imports and use it inside the sw (never tested)? Or maybe you can use import.meta.env inside the sw.

from nuxt.

cawa-93 avatar cawa-93 commented on July 18, 2024

@userquin Yeap. SyntaxError: Cannot use import statement outside a module. Everything looks like the plugin does not process or interact with scripts at all.
зображення

from nuxt.

userquin avatar userquin commented on July 18, 2024

@cawa-93 have you configured devOptions.type = 'module'?

from nuxt.

cawa-93 avatar cawa-93 commented on July 18, 2024

@cawa-93 have you configured devOptions.type = 'module'?

Yes.

    devOptions: {
      enabled: !false,
      type: 'module',
    },

from nuxt.

userquin avatar userquin commented on July 18, 2024

I'm getting this error (elk.zone repo):

...
import { useRuntimeConfig } from 'nuxt/app'
import { onNotificationClick, onPush } from './web-push-notifications'
import { onShareTarget } from './share-target'

declare const self: ServiceWorkerGlobalScope

self.addEventListener('message', (event) => {...})

const singleInstance = useRuntimeConfig().public.singleInstance
console.log('Single Instance', singleInstance)

imagen

from nuxt.

userquin avatar userquin commented on July 18, 2024

I suggest you to provide some process.env variable and use it in define, then access it using import.meta.env in the sw. Reuse the variable for nuxt runtime config entry

from nuxt.

userquin avatar userquin commented on July 18, 2024

Running this script in elk.zone repo "dev:mocked:pwa": "VITE_DEV_PWA=true nuxi dev --port 5314 --dotenv .env.mock",:

imagen

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.