![]() 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. Once webpack knows this, the code can be properly resolved while it is compiling. Aliases are a way to let webpack know where to find our code by providing a word or character that represents a partial reference to where the code is located. I get the following error during the build: ERROR in. After removing it from the path Webpack finally resolves the alias (Actually I am using Encore but in the end it should be similar also for pure Webpack config) let config Encore.getWebpackConfig() '' path.resolve(dirname, 'assets/js') module. Webpack solves these problems by giving us the ability to use aliases. This is how my resolve object looks like: resolve: from 'myApp/utils/myUtils' ![]() The resolver helps webpack find the module code that needs to be included in the bundle for every such. 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. 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: A resolver is a library which helps in locating a module by its absolute path.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |