Angular 发布IIS

1.IIS服务器需要安装插件

  安装 Url

  

 

 

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

2.修改配置

  在src目录下,添加 web.config

<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>

  在angular.json 添加配置

       "build": {
          "options": {
            "assets": [
              "src/favicon.ico",
              "src/assets",
              "src/web.config"
            ],

3.生成

ng build

  在 dist目录下有生成文件,copy到IIS部署即可

posted @ 2021-01-21 09:47  wskxy  阅读(191)  评论(0编辑  收藏  举报