I have a ReactJS application with the following directory structure, App/ - components - - SubComponent1 - - - components - - - - SubSubComponent1 - - - - - components - - - - - .... - - - - - SubSubCompoent1.js - - - SubComponent1.js - - SubComponent2 - - ... - - SubComponent3 - - ... - stores - actions - app.js
Module components
designed in such a way that its entire subcomponent remains inside its directory in the component folder.
Components also have their own components, which are also located in the components folder inside the parent components folder.
Thus, a relative problem is created with the import, and it also becomes erratic with so many levels invested.
If I create all the components under the components of the root application, then there will be many components and who will use the question that will be asked.
So, what I'm asking is, would there be a better directory structure for this kind of scenario?
Soved
In webpack configuration add this,
resolve: { root: __dirname + PATH_TO_APP_ROOT }
Now you can use require('dir/file.js') instead of require('../../../../dir/file.js')
source share