Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the path/file name of index.html in React?

When building a React (with usual react-scripts/create-creact-app etc.) app via npm build, I always get the entry file in build/index.html.

I've tried moving the src into a subfolder, but the index.js is required to be there in src/index.js.

So how can I change the output path of the index.html?

I.e. e.g. I want to rename it to index.htm, because I am have a pedantic quirk, or I want to change the output path to build/srv/www/index.html?

(These are just examples.)

like image 300
rugk Avatar asked Oct 21 '25 17:10

rugk


1 Answers

To change the output path you need to change the webpack config, and in create-react-path is not possible unless you run the eject script.

This way:

npm run eject

After running it, you will be able to access to any project configuration (webpack config in your case), but you must know, once the project is ejected, you can't go back.

More information here:

create-react-app

like image 65
MiguelML Avatar answered Oct 23 '25 05:10

MiguelML



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!