Created
September 4, 2023 16:25
-
-
Save jonathansamines/724443a138e339a4e64b1f6637a663e3 to your computer and use it in GitHub Desktop.
Next.js configuration middleware to enable source maps on server chunks
This file contains 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
function withDebugEnabled(nextConfig) { | |
return { | |
...nextConfig, | |
webpack(conf, options) { | |
// eslint-disable-next-line no-param-reassign | |
if (options.isServer) conf.devtool = 'source-map'; | |
// Overload the Webpack config if it was already overloaded | |
if (typeof nextConfig.webpack === 'function') { | |
return nextConfig.webpack(conf, options); | |
} | |
return conf; | |
}, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment