1

I'd like webpack to search for files in several paths. For example, if i do

import img from './img/smth.png'

in file /src/components/name/index.js, webpack try to search for this file not only in /src/components/name/img/ but also in /src/common/img

Is it possible?

Vladimir Novopashin
  • 1,409
  • 2
  • 11
  • 16

1 Answers1

1

Out of the box, it is not possible to change relative path resolution. Using resolve.alias you can change Webpack resolution for module paths but not for absolute or relative imports.

However, you can write a custom plugin and introduce your own module resolution algorithm. The plugin would be similar to the one implemented here:

Is it possible to create custom resolver in Webpack?

Harshal Patil
  • 17,838
  • 14
  • 60
  • 126