hanford / next-offline

make your Next.js application work offline using service workers via Google's workbox
https://github.com/hanford/next-offline
1.59k stars 111 forks source link

On use swDest in development, the service-worker is generate in other path. #214

Open nathanredblur opened 4 years ago

nathanredblur commented 4 years ago

if you modify the swDest option to generate the serviceworker in other path, this not affect the path to generate the development service-worker.

I need to see the code to fix this, but would be nice to have this in the documentation. this is the fix to generate serviceworker in development in the right path.

  dontAutoRegisterSw: true,
  devSwSrc: {
    from: './public/sw-dev.js',
    to: '../public/service-worker.js',
  },
  workboxOpts: {
    swDest: '../public/service-worker.js',
    offlineGoogleAnalytics: true,
  },

thanks

maysam commented 4 years ago
  workboxOpts: {
    swDest: '../public/service-worker.js',   
  },

is working for me in development environment at https://github.com/maysam/testingnextjs

What I find interesting is that the script is not registering the service-worker.js from the same place it is generating it and why we need to change the swdest, because even in production, you need to change it it you are not using 'now'