3

I want to rename the index.html on dist folder, how i can do that with angular cli on ng build --prod command.

Let me explain why I want to do that, it's for integrate my html page on index.php page, if I don't do that the server reply index.html before index.php and I can't configure the server for launch index.php first.

Thanks for the reply.

2 Answers 2

9
  1. Rename the file index.html to index123.html in the src dir of your project

  2. In the file angular-cli.json modify the index property to look like this:

    "index": "index123.html"

The ng build command will copy the file index123.html into the dist dir.

Sign up to request clarification or add additional context in comments.

3 Comments

Hello, i try this but with ng serve on localhost:4200 you must specify the new name of index : localhost:4200/index123.html and my app doesn't load anymore
ng serve creates the bundles of your Angular app in memory. As per your original question, you wanted to deploy your app under another server where your PHP code is deployed. After running ng build you need to copy the content of the dist dir to the server where your index.php is located.
I generate dist with index.php and index.html, my goal it's to keep ng serve like actually and desploy dist to server without manual action, but if i rename the index.html on src app, my localhost stop to work.
1

Another possibility if you don't control the name of the input file is like this:

"index": {
   "input": "./node_modules/example/index123.html",
   "output": "index.html"
}

In my case this was needed because I work for a customer where all applications are using the same index html template in a node_modules package.

1 Comment

this works for me, aslo can be used for example for styles file name, see github.com/angular/angular-cli/issues/…

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.