首页 > 解决方案 > 排除 node_modules 缩小以解决具有意外路径的“无法缩小此文件中的代码”

问题描述

当我运行 npm run build ( react-app-rewired build) 我得到这个编译错误:

Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file: 

./node_modules/babel-loader/lib??ref--6-oneOf-2!./node_modules/diffusion/src/node_modules/util/interface.js:127 

我正在尝试将excludes属性 config-overrides.js注入为config.optimization.minimizer[0].options.exclude = /node_modules\/diffusion/;

但这似乎不起作用(既不使用 only /node_modules/

有什么帮助吗?

PS。我设法避免在从“生产”到“开发”的配置中完全覆盖“模式”的缩小。

我还注意到我们正在使用 5.9.2 版的扩散库,升级到最新版本后缩小问题就消失了。

不过我的理解是,由于版本 6 中的重大更改,我们需要旧版本。有没有办法只为这个特定的库禁用缩小?

谢谢

标签: javascriptreactjswebpackpush-diffusion

解决方案


推荐阅读