angular multi enviroment

angular 多配置文件设置

添加src/environment/environment.mycusom.ts

1
2
3
export default {
// ...
}

打开项目目录下angualr.json并修改

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
// ...
“build”: {
"configurations": {
"production": {
// ...
},
// 设置自己的enviroment名称
// build with "mycustom" enviroment
"mycustom": {
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.mycustom.ts"
}
}
}
}
// ...
"serve": {
"configurations": {
"production": {
// ...
},
"mycustom": {
"browserTarget": "<appname>:build:mycustom"
}
}
}
}

update package.json.

1
2
3
4
5
6
7
8
9
{
// ...
"script:" {
// ...
"start:local": "ng serve -c local",
"build:local": "ng build -c local"
}
// ...
}

usage

1
2
npm run build:local
npm run start:local

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×