自从2018年5月份,angular 6发布之后,相信用过angualr6的小伙伴一定和我一样,爬了很多坑了吧!下面把我爬过的坑总结一下:
一.angular6 引入ng-zorro,没有样式。。。
解决:在angular.josn文件中,添加 "node_modules/ng-zorro-antd/src/ng-zorro-antd.min.css"
"styles": [ "node_modules/ng-zorro-antd/src/ng-zorro-antd.min.css", "src/styles.css" ],
二. angular配置proxy代理文件无效。。。
解决:在package.json文件中,添加配置项"start": "ng s --proxy-config proxy.config.json --open",
"scripts": { "ng": "ng", "start": "ng s --proxy-config proxy.config.json --open", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" },
三、augular配置环境打包命令
解决方法,直接上代码吧
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
},
"test": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.test.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
}
},
研发环境打包命令:ng build
测试环境打包命令:ng build --configuration=production
正式环境打包命令:ng build --configuration=test