Deploy Angular app to IIS Web Server

After finishing development your Angular 2+ application, I think you would be thinking of what available options to publish your app, there is plenty of options available and described on Angular website but I’m summarizing the list of actions needed to deploy  your app to IIS server.

Deploying Angular 2+ applications to IIS Web server is very easy step, it is only couple of steps.. to do so follow the below steps:

1. Build your AngularJs application for production. to do so type the following command

ng build -prod --output-path [Path]

2. Copy the generated files from step# 1 into your IIS folder.

3. Create a new website for new your application.

4. Create a new web.config file with the following contents:\

<?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="/" />        
             </rule>      
          </rules> 
       </rewrite>   
   </system.webServer> 
</configuration> 

It is very important to make sure that your IIS web Server has the rewrite module installed on it.. the following URL has the downloadable file

https://www.iis.net/downloads/microsoft/url-rewrite