Last active
February 6, 2024 07:54
-
-
Save aweber1/bd322f1501b32bf2c7b0093685916c8c to your computer and use it in GitHub Desktop.
NextJS Webpack disable optimization plugin
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
module.exports = (nextConfig) => { | |
return Object.assign({}, nextConfig, { | |
webpack(webpackConfig, nextContext) { | |
// NOTE: use whatever environment variable you'd like here to determine | |
// what environment should have minimization disabled. | |
if (process.env.NODE_ENV === 'development') { | |
webpackConfig.optimization.minimize = false; | |
webpackConfig.optimization.minimizer = []; | |
} | |
if (typeof nextConfig.webpack === 'function') { | |
return nextConfig.webpack(webpackConfig, nextContext); | |
} | |
return webpackConfig; | |
}, | |
}); | |
}; |
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 withPlugins = require('next-compose-plugins'); | |
const withNextWebpackDisableOptimization = require('./next-webpack-disable-optimization-plugin.js'); | |
const plugins = [ | |
[withNextWebpackDisableOptimization], | |
]; | |
const nextConfig = {}; | |
module.exports = withPlugins(plugins, nextConfig); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment