1.下載Microsoft URL Rewrite Module 2.0 for IIS (x64) https://www.microsoft.com/en-us/download/details.aspx?id=47337

2.無腦安裝
3.安裝angular-cli
npm install -g @angular-cli

如果打包報錯,可以考慮重裝一下
npm uninstall -g angular-cli @angular/cli
npm cache clean
npm install -g @angular/cli
4.打包angular
ng build --prod --aot
5.把打包生成的dist文件夾內容拷貝到iis的網站目錄下
6.在目錄下新建一個web.config文件,寫入內容
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="AngularJS" 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>
7.運行網站
