0

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
  • Because there is some place in your code pointing/importing code from path /public ? Commented May 12, 2019 at 9:39

1 Answer 1

1

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 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.