How to override terserOptions? #30924
-
Hi everyone, I'm using image-blob-reduce package which is not compatible with Terser's "compress" option, so I'm looking for a way to disable it. I've tried to override Next's webpack config in next.config.js as follow:
But it doesn't seem to work. I've also tried to do this:
But then Next doesn't generate the required files (webpack-middleware-hash.js) for middlewares to build. How can I override Terser compress option without breaking the new middleware feature? Thank you in advance for your help |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
For those wanting to use image-blob-reduce with Next 12, I ended up monkey patching Next's webpack config with patch-package. diff --git a/node_modules/next/dist/build/webpack-config.js b/node_modules/next/dist/build/webpack-config.js
index 5fe4dd5..29168a4 100644
--- a/node_modules/next/dist/build/webpack-config.js
+++ b/node_modules/next/dist/build/webpack-config.js
@@ -560,7 +560,8 @@ async function getBaseWebpackConfig(dir, { buildId , config , dev =false , isSer
warnings: false,
// The following two options are known to break valid JavaScript code
comparisons: false,
- inline: 2
+ inline: 2,
+ evaluate: false
},
mangle: {
safari10: true |
Beta Was this translation helpful? Give feedback.
-
I can confirm that this solution works. A few caveats though:
Please contribute also to the issue on the pica repo, which is the base library for image-blob-reducer |
Beta Was this translation helpful? Give feedback.
-
Has anyone else tried this with next.js 13 ? I can't get image-blob-reduce to work in production by applying the patch. |
Beta Was this translation helpful? Give feedback.
For those wanting to use image-blob-reduce with Next 12, I ended up monkey patching Next's webpack config with patch-package.