Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

feat: nextjs pwa #9757

Merged
merged 13 commits into from
Nov 12, 2023
2 changes: 1 addition & 1 deletion .github/workflows/vercel-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:
push:
branches:
- feat-custom-domain
- feat-pwa

jobs:
deploy:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ test-results/

# Sentry Auth Token
.sentryclirc

# PWA
public/sw.js*
public/workbox-*.js*
2 changes: 2 additions & 0 deletions components/PageHead.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default function PageHead(props) {
<meta property="og:type" content={ogType} />
<meta property="og:url" content={ogUrl} />
<meta property="og:image" content={ogImage} />
<link rel="manifest" href="/manifest.json" />

{children}
</Head>
);
Expand Down
62 changes: 36 additions & 26 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { withSentryConfig } from "@sentry/nextjs";
import remarkGfm from "remark-gfm";
import remarkPrism from "remark-prism";
import createMDX from "@next/mdx";
import withPWA from "next-pwa";
import runtimeCaching from "next-pwa/cache.js";

const isProduction = process.env.NODE_ENV === "production";

/** @type {import('next').NextConfig} */
const nextConfig = {
Expand Down Expand Up @@ -49,37 +53,43 @@ const withMDX = createMDX({
},
});

export default withSentryConfig(
withMDX(nextConfig),
{
// For all available options, see:
// https:/getsentry/sentry-webpack-plugin#options
export default withPWA({
dest: "public",
disable: !isProduction,
runtimeCaching,
})(withSentryConfig(

// Suppresses source map uploading logs during build
silent: true,
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
},
{
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
withMDX(nextConfig),
{
// For all available options, see:
// https:/getsentry/sentry-webpack-plugin#options

// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,
// Suppresses source map uploading logs during build
silent: true,
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
},
{
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/

// Transpiles SDK to be compatible with IE11 (increases bundle size)
transpileClientSDK: true,
// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,

// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
tunnelRoute: "/monitoring",
// Transpiles SDK to be compatible with IE11 (increases bundle size)
transpileClientSDK: true,

// Hides source maps from generated client bundles
hideSourceMaps: true,
// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
tunnelRoute: "/monitoring",

// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
// Hides source maps from generated client bundles
hideSourceMaps: true,

// custom
automaticVercelMonitors: false,
},
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,

// custom
automaticVercelMonitors: false,
},
),
);
Loading