Dimitri Kopriwa
Dimitri Kopriwa

Reputation: 14365

How to use alias in webpack to override a dependency already existing in node_modules?

In Webpack 4,

I want to place my rsg-components instead of the one in node_modules.

So react-styleguidist will import my version instead.

Apparently resolve.alias doesn't take precedence over node_modules, is there a way to do so without forking react-stylguidist ?

Upvotes: 3

Views: 4194

Answers (1)

lukas-reineke
lukas-reineke

Reputation: 3322

You can use resolve-modules.
Just add the directory where your module is before node_modules.

From the documentation:

If you want to add a directory to search in that takes precedence over node_modules/:

modules: [path.resolve(__dirname, "src"), "node_modules"]

Upvotes: 5

Related Questions