
In my case, I wanted to alias mobx, so that any import of mobx would always return the same instance, regardless of whether the import call was from my main app, or from within one of the libraries it used.Īt first I had this: webpackConfig.resolve. I also tried with modulesDirectories but it doesn't work either. src/components/Header/index.jsx 33:19-56 Module not found: Error: Cannot resolve module 'myApp/utils/myUtils' in. There we will establish the mapping between the aliases and the physical paths. In order to inform that mapping, we need to open the file and add a new section called resolve.
RESOLVE ALIASES WEBPACK CODE
The resolver helps webpack find the module code that needs to be included in the bundle for every such. Webpack needs to know physical paths that map to the aliases we want to create. In WebStorm, you can choose between two configuration modes - automatic and manual.

A module can be required as a dependency from another module as: The dependency module can be from the application code or a third-party library. Based on the analysis of a webpack configuration file, WebStorm understands the webpack configuration, resolves modules, and provides coding assistance in JavaScript files, see Resolving modules below. I get the following error during the build: ERROR in. A resolver is a library which helps in locating a module by its absolute path. This is how my resolve object looks like: resolve: from 'myApp/utils/myUtils'

I am trying to have a namespace for my app to work as a module, and import my components using this namespace and limit the use of relative path.Īlthough, even though I followed the webpack documentation for alias here:
