Given a directory structure such as:
project
├───common
│ └───js
└───src
└───js
is there any way to add import paths to webpack so that a script inside src/js
can resolve code inside common/js
if it cannot find anything else locally?
Something like the code below would include common/js/CommonClass.js
:
import CommonClass from "CommonClass.js";
This is easy to do for example with compass inside config.rb
:
add_import_path "common/scss"
Webpack accepts multiple resource roots into config.
Now webpack will search modules in both directories as well. Note that option works only with absolute paths.
See webpack docs for more information.