import type { NextConfig } from "next"; import withPWAInit from "@ducanh2912/next-pwa"; const nextConfig: NextConfig = { // No `env` block — NEXT_PUBLIC_ vars are picked up automatically at build time. }; const withPWA = withPWAInit({ dest: "public", // Off in dev. next-pwa writes sw.js + workbox-*.js into `dest` on every // compile, and the dev server watches public/ — so leaving it on makes each // build trigger the next one, forever. A dev service worker also serves // stale assets against HMR. Production builds are unaffected. disable: process.env.NODE_ENV === "development", cacheOnFrontEndNav: true, aggressiveFrontEndNavCaching: true, reloadOnOnline: true, register: true, workboxOptions: { cleanupOutdatedCaches: true, clientsClaim: true, skipWaiting: true }, }); export default withPWA(nextConfig);