Angular部署到windows上


1. 確保已經打開了IIS服務。

  如果沒有打開可參考 http://jingyan.baidu.com/article/eb9f7b6d9e73d1869364e8d8.html

2. 編譯angular程序  ng build --prod --aot.

   編譯后項目中會出現dist文件夾

3. 在IIS中添加網站

 

4. 將編譯后的dist文件夾添加到網站中

 

 

5. 安裝URL Rewrite Module

因為Angular無刷新的特性,所以瀏覽器地址欄上的網址其實不會真實映射到磁盤的特定位置,所以我們需要安裝

下載地址: https://www.microsoft.com/en-us/download/details.aspx?id=47337 <https://www.microsoft.com/en-us/download/details.aspx?id=47337>

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

 

7. 如果項目中有資源文件 需要將資源文件拷入到dist中

 

8. 設置dist文件夾的權限 最簡單的可以設置為以下

 

 

 

*轉載請附出處 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM