Reputation: 11
How to use import "assets/css/"
in any directory within my app
instead of this import "../assets/css/"
Upvotes: 0
Views: 793
Reputation: 2319
I think you should keep your file in the public Folder and then you can try this directly without importing.
Reference:
https://stackoverflow.com/a/63961058/8425297
Upvotes: 0
Reputation: 11601
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'] };
Upvotes: 1