将 Angular 应用程序部署到 Azure Web 应用程序的问题 Angular 9
Issue Deploying Angular App to Azure Web Apps Angular 9
我有一个 angular 应用程序。
这是 package.json
的一部分
"version": "0.0.1",
"main": "dist/index.html",
"files": [ "dist/" ],
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"build-prod": "ng build --prod"
},
在src文件夹
下包含一个web.config
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
<rewrite>
<rules>
<rule name="Angular" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="index.html" appendQueryString="true"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
在我的 Angular.json 中,我将其添加到资产下
"assets": [
"src/favicon.ico",
"src/assets",
"src/web.config"
],
我在 azure devops 中有以下步骤
我在我的 azre 网络应用程序中设置了一个虚拟目录
这是我得到的错误
问题是自己造成的。我的虚拟目录路径缺少 \dist
的一级
它被设置为 site\wwwroot\package\AngularApp 而不是 site\wwwroot\package\dist\AngularApp
我有一个 angular 应用程序。 这是 package.json
的一部分 "version": "0.0.1",
"main": "dist/index.html",
"files": [ "dist/" ],
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"build-prod": "ng build --prod"
},
在src文件夹
下包含一个web.config<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
<rewrite>
<rules>
<rule name="Angular" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="index.html" appendQueryString="true"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
在我的 Angular.json 中,我将其添加到资产下
"assets": [
"src/favicon.ico",
"src/assets",
"src/web.config"
],
我在 azure devops 中有以下步骤
这是我得到的错误
问题是自己造成的。我的虚拟目录路径缺少 \dist
的一级它被设置为 site\wwwroot\package\AngularApp 而不是 site\wwwroot\package\dist\AngularApp