我创建了一个 Angular 5 网站,我想使用 Webform 或 MVC 部署给客户,我只想更改 webconfig 文件中的一些变量(dbconnection、名称等),但是使用 Angular 我不知道如何去做吧。那么每次部署的时候都要重新构建,那么有没有办法解决这个问题呢?
尝试将其添加为带有文件夹web.config的文件dist
<?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="./index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
有关更多信息,我建议阅读这篇文章:https://medium.com/angular-in-depth/deploy-an-angular-application-to-iis-60a0897742e7
Saj*_*ran -1
您应该使用environment.ts并在其中添加任何端点。
像这样的事情,
环境.ts 文件:
export const environment = {
production: false,
apiBase: 'http://dev-server:4200/app/',
env: 'dev'
};
Run Code Online (Sandbox Code Playgroud)
这是一个good article带有 Angular cli 的真正的环境文件:
| 归档时间: |
|
| 查看次数: |
22649 次 |
| 最近记录: |