I need to add a React app in the middle of my website. and This app' files (which source code is available to me) is as follows:

the app:
|  |____...
|  |____index.html
|  |____put some files here // This is the reason for my question
   |___the rest of files! 

why does it need me to put some files in the index.html directory? How do I change that?

1 Answers

behnam shateri On

because your app must be render on element that you set in 'index.js', this html element is in an html file with 'html' & 'body' tag that by default its named 'index.html' in 'public' directory. if you want to change that you can run "npm run eject" script. It moves create-react-app’s configuration files and dev/build/test scripts into you app directory. you can set this script in package.json file :

"scripts": {
   "eject": "react-scripts eject",

after eject all setting, its build a directory by name of 'config' and by edditing in 'path.js' you can change this file as you want:

appPublic: resolveApp('public'), // for changing public directory
appHtml: resolveApp('public/index.html'), // for changing index.html file