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:
|__node_modules:
|  |____...
|
|__public:
|  |____index.html
|  |____put some files here // This is the reason for my question
|
|__src:
   |___index.js
   |___app.jsx 
   |___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

0
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