I have created an angular 5 web site, with Webform or MVC I want to deploy to customers, I just want to change some variables (dbconnection, name, ...) in the webconfig file, but with angular I don't know how to do it. So every time I deploy, I have to build again, so is there a way to solve this problem?
Asked
Active
Viewed 1.3k times
2 Answers
4
try to add this as web.config file with dist folder
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="./index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
for more i recommend reading this article: https://medium.com/angular-in-depth/deploy-an-angular-application-to-iis-60a0897742e7
Muhammed Moussa
- 3,365
- 28
- 19
-
If you do this but get an error about a malformed xml document, you need the "IIS rewrite" module added to IIS: https://www.iis.net/downloads/microsoft/url-rewrite . Otherwise it cannot understand what
means. – Dean Aug 03 '20 at 20:45
-1
You should use the environment.ts and add whatever your endpoints there.
Something like this,
environment.ts file:
export const environment = {
production: false,
apiBase: 'http://dev-server:4200/app/',
env: 'dev'
};
Here is a really good article on environment files with angular cli:
Sajeetharan
- 203,447
- 57
- 330
- 376