Open Firhan384 opened 2 years ago
I'm also dealing with that problem.
Hey, there seems to be a workaround for now that has been mentioned here:
https://github.com/cyrilwanner/next-compose-plugins/issues/59#issuecomment-1230325393
I'm also dealing with that problem.
yes, like @webwelten mentioned and the readme says, you should modified your next.config.js like this:
const withPWA = require('next-pwa')({
dest: 'public'
})
module.exports = withPWA({
// next.js config
// reactStrictMode: true,
})
`/* @type {import("next").NextConfig} /
const runtimeCaching = require("next-pwa/cache"); const withPWA = require("next-pwa")({ pwa: { dest: "public", register: true, skipWaitings: true, runtimeCaching, disabled: process.env.NODE_ENV === "development", sw: "sw.js" } })
const nextConfig = { reactStrictMode: true, i18n: { locales: ["pt", "en"], defaultLocale: "pt" }, react: { useSuspense: true, }, swcMinify: true, };
module.exports = [nextConfig, withPWA]; `
Summary
i have a bugs, when i build in local and started my project no problem, when i'm trying to make a docker image, i got error.
Versions
next-pwa
: 5.6.0next
: 12.2.5How To Reproduce
module.exports = withPWA({ pwa: { dest: 'public', register: true, skipWaiting: true } });`
RUN apk add --no-cache libc6-compat WORKDIR /app COPY package.json ./ RUN yarn install --frozen-lockfile
FROM node:16-alpine AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . .
RUN yarn build
FROM node:16-alpine AS runner WORKDIR /app
ENV NODE_ENV production
RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/.next/sw.js ./public COPY --from=builder /app/.next/workbox-*.js ./public/
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT 3000
CMD ["node", "server.js"]`
{ "name": "test-pwa", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "format": "prettier --write \"./**/*.{js,json}\"" }, "dependencies": { "next": "12.2.5", "next-pwa": "^5.6.0", "react": "18.2.0", "react-dom": "18.2.0" }, "devDependencies": { "@types/node": "18.7.14", "@types/react": "18.0.18", "@types/react-dom": "18.0.6", "eslint": "8.23.0", "eslint-config-next": "12.2.5", "prettier": "^2.7.1", "typescript": "4.8.2" } }
Screenshots