Home > Software design >  How to import files outside src in crete-react-app
How to import files outside src in crete-react-app

Time:04-14

In general, I have a project that contains the app and lib folders. in the 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.

app
   > electron
   > viewer
   > web
lib
   > base
   > game

but in create-react-app the webpack is configured so that I cannot import outside the src folder. I tried to write in .env NODE_PATH = ./../../ and it helped, but other errors were already pouring in: You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See webpack.js.org - points to my exported component from there. Help, how can I make the lib / base repository a library and import everything I need from there in a project that lies outside. Thank you

CodePudding user response:

You would need to eject from Create React App and then modify your webpack config to allow it to search directories other than src/

  • Related