使用自定义配置运行ng build [英] Run ng build with custom configurations
本文介绍了使用自定义配置运行ng build的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有Angular项目,我想将其部署在Apache服务器上.我使用ng build
,但我想为后端自定义地址和端点.
I have Angular project which I would like to deploy on Apache server. I use ng build
but I would like to custom address and endpoint for backend.
proxy.conf.json:
proxy.conf.json:
{
"/api/*": {
"target": "http://localhost:8080",
"secure": false,
"logLevel": "debug",
"changeOrigin": true
}
}
完全不应用此配置. 如何正确设置以便更改配置?
This configuration is not applied at all. How I can set it properly in order to change configurations?
环境ts文件:
import {environment as prod} from './environment.prod';
export const environment = Object.assign(prod, {
production: false
});
推荐答案
假定您正在使用Angular(> v6),并且已根据要求创建了多个环境文件.
Assuming you are using Angular (>v6), and you have created multiple environment files as per requirements.
所以您需要做的是转到angular.json文件
So what you need to do is, go to angular.json file
angular.json > projects > projectName > architect > build > configurations > fileReplacements
,在这里您需要用这样的文件名替换文件名-
and here you need to replace files name with your files name like this -
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.live.ts"
这篇关于使用自定义配置运行ng build的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文