自從2018年5月份,angular 6發佈以後,相信用過angualr6的小夥伴必定和我同樣,爬了不少坑了吧!下面把我爬過的坑總結一下:javascript
一.angular6 引入ng-zorro,沒有樣式。。。css
解決:在angular.josn文件中,添加 "node_modules/ng-zorro-antd/src/ng-zorro-antd.min.css"java
"styles": [ "node_modules/ng-zorro-antd/src/ng-zorro-antd.min.css", "src/styles.css" ],
二. angular配置proxy代理文件無效。。。node
解決:在package.json文件中,添加配置項"start": "ng s --proxy-config proxy.config.json --open",json
"scripts": { "ng": "ng", "start": "ng s --proxy-config proxy.config.json --open", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" },
3、augular配置環境打包命令antd
解決方法,直接上代碼吧測試
"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 buildui
測試環境打包命令:ng build --configuration=productionspa
正式環境打包命令:ng build --configuration=test代理