2

Is there any way to make the angular paths take the base href attribute of the index.html file after building the application, so that if I change the base href value the app makes the requests to another url without building the app again?

I know I can achieve this by adding baseHref to angular.json

"architect": {
   "build": {
      "builder": "@angular-devkit/build-angular:browser",
      "options": {
         "baseHref" : "/MyApp/"
      }
   }
}

But I'm trying to avoid rebuilding every time.

I also thought changing my iis site configuration, but I have multiple applications inside my site so updating the site config would break those:

  • Site
    • Application 1
    • Application 2
    • MyApp

Thanks!

2 Answers 2

1

It is Web server work (not Angular Router). I faced with the same problem with i18n. (Some usefull article for this case: https://medium.com/@feloy/deploying-an-i18n-angular-app-with-angular-cli-fc788f17e358)

1) I build two diferent application with: baseHref="/" and "baseHref": "/fr/".

2) Then config IIS web.config to switch betweeen thouse two application.

Hope its help!

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

2 Comments

Thanks for your answer! The problem is that I have multiple applications inside my iis site, so if I change the site configuration the other apps would not work :(
May be its help: stackoverflow.com/questions/28049253/… (I belive you can config Web.config hierarchy for all sites separately)
1

Try the following configuration:

"options": {
          "configurations": {
            "production": {
              "baseHref": "/MyApp/",
              "deployUrl": "/MyApp/"

            }

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.