Next.js plugin for generating a Workbox. Intended to be used alongside @next-with-offline/react-hook and @next-with-offline/service-worker. Read the top level documentation for more information about usage.
yarn add @next-with-offline/next-plugin
Update or create next.config.js
with
const withOffline = require("@next-with-offline/next-plugin");
module.exports = withOffline({
offline: {
path: "/offline",
},
workbox: {
dest: "public",
swDest: "sw.js",
swSrc: "worker.js",
// .
// ..
// ... other workbox-webpack-plugin.InjectManifest options
},
// .
// ..
// ... other Next.js config
});
Add public/sw.js
and public/sw.js.map
to your .gitignore
public/sw.js
public/sw.js.map