搜过很多文章说的都是关于Angular4的配置,后面自己又找了许多资料,最后总结了Angular6 如何配置开发环境,测试环境,生产环境:
1、在environments文件夹里新建三个文件:
//生产环境
environment.prod.ts:
export const environment = {
production: true,
url : 'http://xxx',
url2 : 'http://xxx',
url3 : 'http://xxx',
};
//测试环境
environment.test.ts:
export const environment = {
production: false,
url : 'http://xxx',
url2 : 'http://xxx',
url3 : 'http://xxx'
};
//本地环境
environment.ts:
export const environment = {
production: false,
url : 'http://xxx',
url2 : 'http://xxx',
url3 : 'http://xxx',
};
2、重点是第二步(有别于Angular4):
找到angular.json文件
找到 projects - architect - build - configurations 配置如下:
"production": {
"optimization": true,
"outputHashing": "all"