Reputation: 11617
I am using create-react-app
command to create an empty app, I got these file in src
folder:
App.css
App.js
App.test.js
index.css
index.js
logo.svg
serviceWorker.js
setupTests.js
After I make a build via npm run build
, index.html
is generated in build
folder.
I created one manually in src
folder, but the build doesn't take it.
The index.js
content is:
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
There is no root
element at all.
I need to add in some <script>
tag inside index.html
to include some third party scripts (which cannot be installed by nodejs), where can I add them since it is not existed in src
folder?
Upvotes: 2
Views: 11832
Reputation: 5603
You should download that third party lybrairie and put it inside of the public directory and include a script
tag inside of the index.html
file which is inside of the public
directory of your project.
The configuration of the create-react-app
is using webpack which is preconfigure to load the public\index.html
file as the template in which the compiled bundle will be injected.
If you want to use the index.html
file which you have create inside of the src
folder you should run npm run eject
which will put all create-react-app configuration at your disposal in your project directory and you could perform changes to webpack figuration file to load src/index.html
file as the template in which the compiled bundle will be injected.
Upvotes: 1
Reputation: 661
You have to check public folder in the root directory only. You will get your index.html would be there. and your index.js file which is in src folder is the single point of connection between them(main index.html in public folder and all Javascript code which is in src folder).
Upvotes: 10