|
| 1 | +import { config } from 'dotenv' |
1 | 2 | import type { NextConfig } from 'next'
|
2 | 3 |
|
| 4 | +import { withSentryConfig } from '@sentry/nextjs' |
| 5 | +import { sentryWebpackPlugin } from '@sentry/webpack-plugin' |
3 | 6 | import { createVanillaExtractPlugin } from '@vanilla-extract/next-plugin'
|
4 | 7 |
|
5 | 8 | const withVanillaExtract = createVanillaExtractPlugin()
|
6 | 9 |
|
7 |
| -/** @type {import('next').NextConfig} */ |
8 |
| -const nextConfig: NextConfig = { |
| 10 | +process.title = 'Kami (NextJS)' |
| 11 | + |
| 12 | +const env = config().parsed || {} |
| 13 | +const isProd = process.env.NODE_ENV === 'production' |
| 14 | + |
| 15 | +// eslint-disable-next-line import/no-mutable-exports |
| 16 | +let nextConfig: NextConfig = { |
9 | 17 | experimental: {
|
10 | 18 | appDir: true,
|
11 | 19 | },
|
| 20 | + webpack: (config, options) => { |
| 21 | + if ( |
| 22 | + process.env.SENTRY === 'true' && |
| 23 | + process.env.NEXT_PUBLIC_SENTRY_DSN && |
| 24 | + isProd |
| 25 | + ) { |
| 26 | + config.plugins.push( |
| 27 | + sentryWebpackPlugin({ |
| 28 | + include: '.next', |
| 29 | + ignore: ['node_modules', 'cypress', 'test'], |
| 30 | + urlPrefix: '~/_next', |
| 31 | + |
| 32 | + org: 'inneis-site', |
| 33 | + headers: { |
| 34 | + Authorization: `DSN ${process.env.NEXT_PUBLIC_SENTRY_DSN}`, |
| 35 | + }, |
| 36 | + project: 'kami', |
| 37 | + }), |
| 38 | + ) |
| 39 | + } |
| 40 | + |
| 41 | + return config |
| 42 | + }, |
12 | 43 | }
|
13 | 44 |
|
14 |
| -export default withVanillaExtract(nextConfig) |
| 45 | +if (process.env.SENTRY === 'true' && isProd) { |
| 46 | + // @ts-expect-error |
| 47 | + nextConfig = withSentryConfig( |
| 48 | + nextConfig, |
| 49 | + { |
| 50 | + // For all available options, see: |
| 51 | + // https://github.com/getsentry/sentry-webpack-plugin#options |
| 52 | + |
| 53 | + // Suppresses source map uploading logs during build |
| 54 | + silent: true, |
| 55 | + |
| 56 | + org: 'inneis-site', |
| 57 | + project: 'springtide', |
| 58 | + }, |
| 59 | + { |
| 60 | + // For all available options, see: |
| 61 | + // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/ |
| 62 | + |
| 63 | + // Upload a larger set of source maps for prettier stack traces (increases build time) |
| 64 | + widenClientFileUpload: true, |
| 65 | + |
| 66 | + // Transpiles SDK to be compatible with IE11 (increases bundle size) |
| 67 | + transpileClientSDK: true, |
| 68 | + |
| 69 | + // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load) |
| 70 | + tunnelRoute: '/monitoring', |
| 71 | + |
| 72 | + // Hides source maps from generated client bundles |
| 73 | + hideSourceMaps: true, |
| 74 | + |
| 75 | + // Automatically tree-shake Sentry logger statements to reduce bundle size |
| 76 | + disableLogger: true, |
| 77 | + }, |
| 78 | + ) |
| 79 | +} |
| 80 | + |
| 81 | +nextConfig = withVanillaExtract(nextConfig) |
| 82 | + |
| 83 | +export default nextConfig |
0 commit comments