next-pwa
next-pwa copied to clipboard
Service Worker not generated in public folder
Summary
Starting with version 5.5.5 when running npm run build
no sw.js
and no workbox-*.js
file is generated in the public
folder. When downgrading to 5.5.4 everything works as expected.
Versions
-
next-pwa
: 5.5.5 -
next
: 12.2.3
How To Reproduce
Steps to reproduce the behavior:
- Setup a fresh installation of
next
withnext-pwa
(following the official next-pwa docs) - run
npm run build
- See
sw.js
andworkbox-*.js
only in.next
folder but not inpublic
folder.
Additional Context
next.config.js:
const withPWA = require('next-pwa')
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
pwa: {
dest: 'public',
register: true,
}
}
module.exports = withPWA(nextConfig)
5.5.4 only works when we provide a version in package.json like "5.5.4" and the same issue is repro for version: "^5.5.4"
Same issue. next version 12.2.3 and next-pwa 5.5.4 not generating files.
Temp fix by copying files to .next folder and serve as file
same issue...
Same problem here !!!
Temp fix: downgrade to 5.4.0v
Solved by leaving the config empty:
const withPWA = require("next-pwa");
module.exports = withPWA({
});
Same problem +1
Solved by leaving the config empty:
const withPWA = require("next-pwa"); module.exports = withPWA({ });
Tried but still the same issue
Temp fix: downgrade to 5.4.0v
Nextjs with 12.2.3 and PWA 5.4.0 is not working, still same issue
Downgrade to [email protected]
I just downgraded to [email protected] with [email protected] And working fine for me.
Next-pwa 5.5.5 have bug Please downgrade to 5.5.4 it will work
Thank you everyone
I downgraded and still not wroking
Try with fresh approach.
Hi everyone. Need to remove this symbol ^ in next-pwa": "^5.5.4" and install version 5.5.4
Hi everyone. Need to remove this symbol ^ in next-pwa": "^5.5.4" and install version 5.5.4
Yeah, I figured out this later. Thanks!
Could this be fixed soon?
I just downgraded to [email protected] with [email protected] And working fine for me.
This works for me "next-pwa": "5.5.4",
Same problem ...
None of the versions working, tried all... "next": "^12.2.5"
Guyz Just install [email protected] .
@shadowwalker is there any final resolution for this? The only "solution" mentioned in this thread is downgrading to 5.5.4, which seems to be incompatible with the new config format in next.config.js
described in next-pwa documentation. And next-pwa
is on 5.6.0 now...
@iacobfred it looks like https://github.com/shadowwalker/next-pwa/pull/372 fixed this, so the latest next-pwa
version should work fine.
@Yorkshireman thanks. I just realized that the problem was actually with my build process in my multistage Dockerfile. I was copying the public
dir from the host rather than from the builder stage, so it didn't include the service worker files that were generated during the builder stage.
I still have the same problem with next 13.4 and next-pwa ^5.6.0
Had the same issue with ^5.6.0
.
Adding the manual copying to package.json seemingly fixed that:
"postbuild": "cp build/sw.js build/workbox-* public/",