Skip to content

Instantly share code, notes, and snippets.

@aweber1
Last active February 6, 2024 07:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aweber1/bd322f1501b32bf2c7b0093685916c8c to your computer and use it in GitHub Desktop.
Save aweber1/bd322f1501b32bf2c7b0093685916c8c to your computer and use it in GitHub Desktop.
NextJS Webpack disable optimization plugin
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;
},
});
};
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