Answer the question
In order to leave comments, you need to log in
How to import files outside of src in create-react-app?
In general, I have a project inside which are the app and lib folders. in base I should have all the components, in short, this is my component library and from there I need to import what I need into the project into the app folder.
but in create-react-app webpack is configured so that I can't import outside the src folder.
I tried to write NODE_PATH = ./../../ in .env and it helped, but other errors were already falling:
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders - points to my exported component from there.
Help me, how can I make the lib/base repository a library and import everything I need from there in the project that lies outside. Thanks
Answer the question
In order to leave comments, you need to log in
It's made on purpose. Without eject, it is not possible to import anything outside of the src folder, except for the package.json file.
Package the libraries as an npm package and use them in your application. During development, you can use npm link.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question