Closed seraj closed 3 years ago
The service worker is generated in the _next/static
directory. It can be accessed via this route.
So, one thing you could do is set a redirect rule to help with that.
UPDATE:
i use fs
package to copy service-worker.js
to public folder and it's work.
thank you
copy-sw.js
:
const fs = require(`fs`).promises;
Promise.all(
[`service-worker.js`].map((fileName) =>
fs.copyFile(`./.next/static/${fileName}`, `./public/${fileName}`).then(() => fileName),
),
).then((fileNames) =>
console.log(`The following files were copied to './static': ${JSON.stringify(fileNames)}`),
);
add this script to package.json
"copy-sw": "node copy-sw.js",
"build": "next build && yarn copy-sw",
UPDATE: i use
fs
package to copyservice-worker.js
to public folder and it's work. thank you
copy-sw.js
:const fs = require(`fs`).promises; Promise.all( [`service-worker.js`].map((fileName) => fs.copyFile(`./.next/static/${fileName}`, `./public/${fileName}`).then(() => fileName), ), ).then((fileNames) => console.log(`The following files were copied to './static': ${JSON.stringify(fileNames)}`), );
add this script to
package.json
"copy-sw": "node copy-sw.js", "build": "next build && yarn copy-sw",
Cool. That works! Closing this issue as it's already resolved.
hi thanks for this awesome repo
I use this repo for my project and it's working fine. but one thing happen for me.
I don't deploy it on now or Heroku. we have our server and I just use ssh for deploying the project on the server.
and this is my console