Created
November 7, 2025 18:54
-
-
Save jasonLaster/80a89e845ccce2979ae6131ce8e1feff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Next.js 15 Configuration | |
| * | |
| * Build System: | |
| * - Turbopack (not webpack) - Fast bundler for development and production | |
| * - SWC Compiler - Rust-based JavaScript/TypeScript compiler | |
| * | |
| * Key Features: | |
| * - Standalone output for containerized deployments | |
| * - OpenTelemetry instrumentation with proper bundling (not externalized) | |
| * - Sentry integration for error monitoring | |
| * - Vercel Toolbar integration | |
| * - Image optimization with modern formats | |
| * - SVG handling via @svgr/webpack | |
| */ | |
| import { withSentryConfig } from "@sentry/nextjs"; | |
| import type { NextConfig } from "next"; | |
| import withVercelToolbar from "@vercel/toolbar/plugins/next"; | |
| const nextConfig: NextConfig = { | |
| output: "standalone", | |
| // Build optimizations | |
| // Note: Using Turbopack (not webpack) with SWC compiler | |
| experimental: { | |
| // Enable faster builds with comprehensive package import optimization | |
| optimizePackageImports: [ | |
| "lucide-react", | |
| "@radix-ui/react-icons", | |
| "@emotion/react", | |
| "@emotion/styled", | |
| "lodash", | |
| "date-fns", | |
| "recharts", | |
| "react-day-picker", | |
| "react-markdown", | |
| "zod", | |
| "clsx", | |
| "tailwind-merge", | |
| "class-variance-authority", | |
| "cmdk", | |
| "sonner", | |
| "nuqs", | |
| ], | |
| // Optimize CSS - disabled due to critters dependency issue | |
| // optimizeCss: true, | |
| }, | |
| // Avoid externalizing client-side libs to prevent duplicate React copies in standalone output | |
| // serverExternalPackages: [], | |
| // Turbopack configuration with performance optimizations | |
| turbopack: { | |
| rules: { | |
| "*.svg": { | |
| loaders: ["@svgr/webpack"], | |
| as: "*.js", | |
| }, | |
| }, | |
| // Handle ESM modules properly in Turbopack and ensure OpenTelemetry packages are bundled | |
| resolveAlias: { | |
| "@emotion/react/jsx-runtime": "@emotion/react/jsx-runtime", | |
| // Ensure OpenTelemetry packages are resolved and bundled properly | |
| "@opentelemetry/instrumentation": "@opentelemetry/instrumentation", | |
| "require-in-the-middle": "require-in-the-middle", | |
| "import-in-the-middle": "import-in-the-middle", | |
| }, | |
| // Performance optimizations | |
| resolveExtensions: [".js", ".jsx", ".ts", ".tsx", ".json"], | |
| }, | |
| // Enable sourcemap generation for better debugging | |
| productionBrowserSourceMaps: true, | |
| // SWC Compiler optimizations | |
| compiler: { | |
| // Remove console.logs in production (except error and warn) | |
| removeConsole: | |
| process.env.NODE_ENV === "production" | |
| ? { | |
| exclude: ["error", "warn", "log"], | |
| } | |
| : false, | |
| // Enable SWC styled components support if needed | |
| styledComponents: false, | |
| // Enable SWC emotion support for better performance | |
| emotion: true, | |
| }, | |
| // Image optimization | |
| images: { | |
| formats: ["image/webp", "image/avif"], | |
| deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840], | |
| imageSizes: [16, 32, 48, 64, 96, 128, 256, 384], | |
| }, | |
| // Performance optimizations | |
| poweredByHeader: false, | |
| generateEtags: false, | |
| // Enable compression | |
| compress: true, | |
| }; | |
| const sentryConfig = withSentryConfig(nextConfig, { | |
| // For all available options, see: | |
| // https://www.npmjs.com/package/@sentry/webpack-plugin#options | |
| org: "autonomy-mm", | |
| project: "autonomy-circuit", | |
| // Only print logs for uploading source maps in CI | |
| silent: true, | |
| // For all available options, see: | |
| // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/ | |
| // Upload a larger set of source maps for prettier stack traces (increases build time) | |
| widenClientFileUpload: true, | |
| // Enable sourcemap uploads | |
| sourcemaps: { | |
| // Automatically upload source maps during build | |
| disable: false, | |
| // Upload source maps to Sentry | |
| assets: ["**/*.js", "**/*.js.map"], // Specify which files to upload | |
| ignore: ["node_modules"], | |
| }, | |
| // Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers. | |
| // This can increase your server load as well as your hosting bill. | |
| // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client- | |
| // side errors will fail. | |
| tunnelRoute: "/monitoring", | |
| // Automatically tree-shake Sentry logger statements to reduce bundle size | |
| disableLogger: true, | |
| // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.) | |
| // See the following for more information: | |
| // https://docs.sentry.io/product/crons/ | |
| // https://vercel.com/docs/cron-jobs | |
| automaticVercelMonitors: true, | |
| }); | |
| export default withVercelToolbar()(sentryConfig); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment