Background Sync

lhp0
0
lhp0
commented 8 months ago

I am trying to build a nuxt PWA with background sync feature, i created background_sync.js under /static folder with this piece of code copied from Google Workbox Doc.

if (workbox) {
    console.log(`Yay! 'background_sync.js' is loaded ๐ŸŽ‰`);

    const bgSyncPlugin = new workbox.backgroundSync.Plugin('myQueueName', {
        maxRetentionTime: 24 * 60 // Retry for max of 24 Hours (specified in minutes)
    });

    workbox.routing.registerRoute(
        /\/api\/.*/,
        new workbox.strategies.NetworkOnly({
            plugins: [bgSyncPlugin]
        }),
        'GET'
    );

} else {
    console.log(`Boo! 'background_sync.js' didn't load ๐Ÿ˜ฌ`);
}

i imported this script file in nuxt.config.js
{
workbox: { importScripts: ["background_sync.js"] }
}
but i got this error when i deploy this SPA to production.
Screenshot 2019-07-29 at 11 41 28 AM

0
lhp0
0
lhp0
commented 8 months ago

fix using this work around,
https://github.com/nuxt-community/pwa-module/issues/196
thanks for your time

0
rcheung9
10
rcheung9
commented 2 months ago

@lhp0 Hi, what work around are you referring to? If possible, can you show a bit of your config / code? Thanks.

0
Informations
Question โ€ข Unresolved
#c154 - Created 8 months ago