Created
October 24, 2024 14:29
-
-
Save blackhaj/52b58c32550dc47cc2addd6ee9bf7f5e to your computer and use it in GitHub Desktop.
Next Config
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
| const { patchWebpackConfig } = require('next-global-css'); | |
| const withBundleAnalyzer = require('@next/bundle-analyzer')({ | |
| enabled: process.env.ANALYZE === 'true', | |
| }); | |
| const { configureRuntimeEnv } = require('next-runtime-env/build/configure'); | |
| const { patchSass } = require('./config/patch-sass'); | |
| const { patchSvgs } = require('./config/patch-svgs'); | |
| const { patchVideos } = require('./config/patch-videos'); | |
| const { patchAliases } = require('./config/patch-aliases'); | |
| const { patchRiv } = require('./config/patch-riv'); | |
| const { patchWasm } = require('./config/patch-wasm'); | |
| const { redirects } = require('./config/redirects'); | |
| const { zoomEmbedRewrites, zoomEmbedHeaders } = require('./config/zoom-embed-proxy'); | |
| const isProd = process.env.NODE_ENV === 'production'; | |
| const isTest = process.env.NODE_ENV === 'test'; | |
| if (!isTest) { | |
| configureRuntimeEnv(); | |
| } | |
| /** @type {import('next').NextConfig} */ | |
| const nextConfig = { | |
| images: { | |
| domains: ['t1.gstatic.com'], | |
| }, | |
| transpilePackages: ['ramda'], | |
| reactStrictMode: false, | |
| productionBrowserSourceMaps: true, | |
| compiler: { | |
| styledComponents: { | |
| ssr: true, | |
| }, | |
| }, | |
| eslint: { | |
| // we run lint separately | |
| ignoreDuringBuilds: true, | |
| }, | |
| typescript: { | |
| ignoreBuildErrors: true, | |
| }, | |
| webpack: (config, options) => { | |
| patchSass(config, options, isProd); | |
| patchSvgs(config, options, isProd); | |
| patchRiv(config, options); | |
| patchWasm(config, options); | |
| patchVideos(config, options); | |
| patchAliases(config); | |
| // react-pdf canvas issue: https://github.com/wojtekmaj/react-pdf/blob/v7.x/packages/react-pdf/README.md#nextjs | |
| config.resolve.alias.canvas = false; | |
| // https://nextjs.org/docs/app/building-your-application/optimizing/memory-usage#disable-webpack-cache | |
| if (config.cache && isProd) { | |
| config.cache = Object.freeze({ | |
| type: 'memory', | |
| }); | |
| } | |
| return patchWebpackConfig(config, options); | |
| }, | |
| redirects() { | |
| return redirects; | |
| }, | |
| headers() { | |
| return [...zoomEmbedHeaders]; | |
| }, | |
| rewrites() { | |
| return { | |
| beforeFiles: [ | |
| { | |
| source: '/:path*.map', | |
| destination: '/404', | |
| }, | |
| ], | |
| afterFiles: [...zoomEmbedRewrites], | |
| }; | |
| }, | |
| experimental: { | |
| esmExternals: 'loose', | |
| instrumentationHook: true, | |
| webpackBuildWorker: true, | |
| parallelServerBuildTraces: true, | |
| optimizePackageImports: ['ramda'], | |
| }, | |
| }; | |
| module.exports = withBundleAnalyzer(nextConfig); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment