Skip to content

Instantly share code, notes, and snippets.

@jonathansamines
Created September 4, 2023 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathansamines/724443a138e339a4e64b1f6637a663e3 to your computer and use it in GitHub Desktop.
Save jonathansamines/724443a138e339a4e64b1f6637a663e3 to your computer and use it in GitHub Desktop.
Next.js configuration middleware to enable source maps on server chunks
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