Create-react-app: Feature request: expose index.html template in src folder generated by react-create

Created on 28 Jun 2017  路  7Comments  路  Source: facebook/create-react-app

It is rather inconvenient and confusing to have the index.html having a title React App.
Besides one may choose include some static assets, for example page tracking scripts doesn't really live too well with React.

question

Most helpful comment

@Haocen you may edit the index.html inside of the public/ folder so that it "persists" through rebuilds.

All 7 comments

Could you explain the request more? I'm not sure what exactly you are suggesting.

Do you want the default title to be different? How is this related to the src folder?

You can also include page tracking (and other) scripts by including them in the public folder alongside HTML. They work fine in React.

We'll need more information about what you're trying to do. This request is not exactly clear to me. Thanks!

Example:

The artifact built by npm run build will be automatically harvested and deployed by my system, so I would expect it to be ready after the script return.

If I want to change the title of the generated index.html inside build folder, I have to go into node_modules/react-scripts/template and modified the index.html template there, thus does not survive another npm install or git checkout.

If the index.html is put in src folder and exposed in the template created by react-create it will be easier to persist the changes I made.

@Haocen you may edit the index.html inside of the public/ folder so that it "persists" through rebuilds.

I have "react-scripts": "^1.0.7"
Steps to reproduce problem:

  1. do npm build
  2. modify the index.html(a minified file) inside build folder
  3. modify the App.js in src folder
  4. do npm build agian
  5. all changes done to index.html are gone, everything inside comes from react-scripts/template/index.html now

You should be modifying the index.html file in the public/ folder, not the build/ folder.

I just realized the problem: I dynamically generate that index.html inside public folder with ejs when the server start.

I believe it also happens to whomever try to do React server side rendering,

I would really appreciate that if anybody can propose a solution without running that server once before doing npm build

I'm really not sure what you're asking now, but this isn't an issue with us.
Please open a question on Stack Overflow or a React community such as reactiflux.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DaveLindberg picture DaveLindberg  路  3Comments

alleroux picture alleroux  路  3Comments

alleroux picture alleroux  路  3Comments

fson picture fson  路  3Comments

ap13p picture ap13p  路  3Comments