shadowwalker / next-pwa

Zero config PWA plugin for Next.js, with workbox 🧰
MIT License
3.86k stars 323 forks source link

error after build image with docker [WebpackGenerateSW] 'pwa' property is not expected to be here #398

Open Firhan384 opened 2 years ago

Firhan384 commented 2 years ago

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

How 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"]`

Screenshots

Screen Shot 2022-09-01 at 12 48 13

vinocrzy commented 2 years ago

I'm also dealing with that problem. image

webwelten commented 2 years ago

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

jaywhen commented 2 years ago

I'm also dealing with that problem. image

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, 
})
FelipeSimoesDaRocha commented 1 year ago

for me it works:

`/* @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]; `