How to use import "assets/css/" in any directory within my app
instead of this import "../assets/css/"
How do i have an assets file that i can use in any file in my react app without always having to navigate to the assets folder
478 Views Asked by Johny Whyte At
3
There are 3 best solutions below
3
On
It called Absolute Path Imports
If you using create-react-app, create file called .env with following content at the root of your project and restart the dev server and you are good to go:
NODE_PATH=src/
Otherwise add following to webpack.config.js (Module Resolution):
resolve: { modules: [path.resolve(__dirname, './src'), 'node_modules'] };
I think you can use postinstall
It allows you to create aliases for different folders in your app. check it here