如何在 webpack 中使用别名来覆盖 node_modules 中已经存在的依赖项?
How to use alias in webpack to override a dependency already existing in node_modules?
在 Webpack 4 中,
我想放置我的 rsg-components
而不是 node_modules
中的那个。
所以 react-styleguidist
将改为导入我的版本。
显然 resolve.alias
并不优先于 node_modules
,有没有办法在不分叉 react-stylguidist
的情况下做到这一点?
您可以使用 resolve-modules.
只需在 node_modules
.
之前添加您的模块所在的目录
来自文档:
If you want to add a directory to search in that takes precedence over node_modules/:
modules: [path.resolve(__dirname, "src"), "node_modules"]
在 Webpack 4 中,
我想放置我的 rsg-components
而不是 node_modules
中的那个。
所以 react-styleguidist
将改为导入我的版本。
显然 resolve.alias
并不优先于 node_modules
,有没有办法在不分叉 react-stylguidist
的情况下做到这一点?
您可以使用 resolve-modules.
只需在 node_modules
.
来自文档:
If you want to add a directory to search in that takes precedence over node_modules/:
modules: [path.resolve(__dirname, "src"), "node_modules"]