Nice one, But i think this approach is good when you are the only one maintainer of the codebase. For the whole team would suggest using webpack alias.
I think it can be used with n number of maintainer or n number of team also.
As the Package with largest react community also uses this approach.
FYR: github.com/ant-design/ant-design
Nice one, But i think this approach is good when you are the only one maintainer of the codebase. For the whole team would suggest using webpack alias.
webpack.js.org/configuration/resol...
I think it can be used with n number of maintainer or n number of team also.
As the Package with largest react community also uses this approach.
FYR: github.com/ant-design/ant-design
You are correct, and the 5-line setting is tidy and simple. Either way, a team of any size would be using the same settings.
Thanks for the tip, but how can I add this webpack alias when using create-react-app ?
webpack alias not required for CRA. Above config is enough for CRA.
There's also a library called craco that can override configuration for CRA
I second webpack alias. I also suggest using an expressive prefix for the alias so everyone in the team understands that the import uses an alias.
But Nilanth made a good job explaining why some sort of absolute imports makes your life easier.