llanfair
llanfair

Reputation: 1885

webpack: how to get JavaScript from "bower_components", not from "node_modules"

Due the use of main-bower-files as part of the compiling tasks using Gulp, I can't require modules using webpack from node_modules dir because I would mess the CSS's / images / fonts processing tasks in my current asset system. So, how can I tell webpack "when I require something, search into bower_components folder instead in node_modules"?

Upvotes: 0

Views: 59

Answers (1)

Michael Jungo
Michael Jungo

Reputation: 32982

You can use the resolve.modules option in your config:

resolve: {
  modules: ['bower_components']
}

With this it won't check node_modules at all, but if you'd like to fallback to node_modules when the module is not found in bower_components, you can add it as well, the priority is from left to right:

resolve: {
  modules: ['bower_components', 'node_modules']
}

Upvotes: 1

Related Questions