...

/

Absolute Imports and Feature Folders

Absolute Imports and Feature Folders

We'll cover the following...

I prefer to consistently use “absolute import” paths that start from the src folder. Among other things, that makes it easier to move files around, as compared to relative import paths.

Normally, I’d enable that by changing some path resolution options in my Webpack config, but since Create-React-App keeps all the configuration hidden, that’s not an option unless we eject the project. I did some digging around, and it turns out that, at least for now, there’s a semi-undocumented way to enable this in a CRA app without having to eject. If the NODE_PATH environment variable is set, CRA/Webpack will use that in the resolution process. Also, if a .env file ...