Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion next.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
import type { NextConfig } from 'next';
import withPWAInit from '@ducanh2912/next-pwa';

// When running Playwright E2E tests, the dev server must not use
// `output: 'export'` because static export mode is incompatible with
// middleware and the `npm run dev` server that Playwright spins up.
const isE2E = process.env.E2E_TEST === 'true';

const withPWA = withPWAInit({
dest: 'public',
disable: process.env.NODE_ENV === 'development',
register: true,
reloadOnOnline: true,
cacheOnFrontEndNav: true,
extendDefaultRuntimeCaching: true,
workboxOptions: {
runtimeCaching: [
{
urlPattern: ({ url }) => url.pathname.startsWith('/api/'),
handler: 'NetworkFirst',
options: {
cacheName: 'apis',
expiration: {
maxEntries: 16,
maxAgeSeconds: 24 * 60 * 60,
},
networkTimeoutSeconds: 10,
},
},
],
},
});

const nextConfig: NextConfig = {
/* config options here */
...(isE2E ? {} : { output: 'export' }),
Expand All @@ -20,4 +46,5 @@ const nextConfig: NextConfig = {
unoptimized: true,
},
};
export default nextConfig;

export default withPWA(nextConfig);
Loading
Loading