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

How append push notification separate file to service worker? #223

Open hmz22 opened 4 years ago

hmz22 commented 4 years ago

Hi dears. How can append separate file service worker with push notification code in workboxOpt, next.config.js when build. please please.

hmz22 commented 4 years ago

i solved this. my next.config.js:

const path = require("path");
const nextOffline = require("next-offline");

module.exports = nextOffline({
  workboxOpts: {
    importScripts: ["./sw.js"],
    mode: "production",
    swDest: path.join(__dirname, "public/service-worker.js")
  }
});

and i create sw.js in public folder