1通熄、安裝依賴? npm install webpack-bundle-analyzer@^3.0.3
2、對package.json文件進行配置
scripts下添加一條指令:"bundle-report": "webpack-bundle-analyzer dist/stats.json"
3、對angular.json文件進行配置?
????????????"outputPath": "dist",
architect配置如下
"architect": {
? "build": {
? ? "builder": "@angular-devkit/build-angular:browser",
? ? "options": {
? ? ? "outputPath": "dist",
? ? ? "index": "src/index.html",
? ? ? "main": "src/main.ts",
? ? ? "tsConfig": "src/tsconfig.app.json",
? ? ? "polyfills": "src/polyfills.ts",
? ? ? "assets": [
? ? ? ? "src/assets",
? ? ? ? "src/favicon.ico",
? ? ? ? {
? ? ? ? ? "glob": "**/*",
? ? ? ? ? "input": "./node_modules/@ant-design/icons-angular/src/inline-svg/",
? ? ? ? ? "output": "/assets/"
}
? ? ? ],
? ? ? "styles": [
? ? ? ? "node_modules/bootstrap/dist/css/bootstrap.css",
? ? ? ? "node_modules/font-awesome/css/font-awesome.css",
? ? ? ? "node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
? ? ? ? "node_modules/ng-zorro-antd/src/ng-zorro-antd.less",
? ? ? ? "src/styles.scss",
? ? ? ? "src/animate.css"
? ? ? ],
? ? ? "scripts": [
? ? ? ? "node_modules/jquery/dist/jquery.js",
? ? ? ? "node_modules/echarts/dist/echarts.min.js",
? ? ? ? "src/assets/js/fingerprint.js",
? ? ? ? "node_modules/echarts/lib/chart/map/china.js"
? ? ? ]
? ? },
? ? "configurations": {
? ? ? "test": {
? ? ? ? "optimization": false,
? ? ? ? "outputHashing": "all",
? ? ? ? "sourceMap": false,
? ? ? ? "extractCss": true,
? ? ? ? "namedChunks": false,
? ? ? ? "aot": true,
? ? ? ? "extractLicenses": true,
? ? ? ? "vendorChunk": false,
? ? ? ? "buildOptimizer": false,
? ? ? ? "fileReplacements": [
? ? ? ? ? {
? ? ? ? ? ? "replace": "src/environments/environment.ts",
? ? ? ? ? ? "with": "src/environments/environment.test.ts"
? ? ? ? ? }
? ? ? ? ]
? ? ? },
? ? ? "production": {
? ? ? ? "optimization": true,? //? optimization buildOptimizer 兩個參數(shù)改為false不壓縮掘宪,打包后提交大一倍煞肾,但是構建時間減少一倍中贝,上生產改成true梢莽,測試為false
? ? ? ? "outputHashing": "all",
? ? ? ? "sourceMap": false,
? ? ? ? "extractCss": true,
? ? ? ? "namedChunks": false,
? ? ? ? "aot": true,
? ? ? ? "extractLicenses": true,
? ? ? ? "vendorChunk": false,
? ? ? ? "buildOptimizer": true,
? ? ? ? "fileReplacements": [
? ? ? ? ? {
? ? ? ? ? ? "replace": "src/environments/environment.ts",
? ? ? ? ? ? "with": "src/environments/environment.prod.ts"
? ? ? ? ? }
? ? ? ? ]
? ? ? }
? ? }
? },
? "serve": {
? ? "builder": "@angular-devkit/build-angular:dev-server",
? ? "options": {
? ? ? "browserTarget": "micro-service:build",
? ? ? "proxyConfig": "proxy.config.json"
? ? },
? ? "configurations": {
? ? ? "test": {
? ? ? ? "browserTarget": "micro-service:build:test"
? ? ? },
? ? ? "production": {
? ? ? ? "browserTarget": "micro-service:build:production"
}
? ? }
? },
? "extract-i18n": {
? ? "builder": "@angular-devkit/build-angular:extract-i18n",
? ? "options": {
? ? ? "browserTarget": "micro-service:build"
? ? }
? },
? "test": {
? ? "builder": "@angular-devkit/build-angular:karma",
? ? "options": {
? ? ? "main": "src/test.ts",
? ? ? "karmaConfig": "./karma.conf.js",
? ? ? "polyfills": "src/polyfills.ts",
? ? ? "tsConfig": "src/tsconfig.spec.json",
? ? ? "scripts": [
? ? ? ? "node_modules/jquery/dist/jquery.js",
? ? ? ? "node_modules/popper.js/dist/umd/popper.js",
? ? ? ? "node_modules/echarts/dist/echarts.min.js",
? ? ? ? "src/assets/js/fingerprint.js",
? ? ? ? "node_modules/echarts/lib/chart/map/china.js"
? ? ? ],
? ? ? "styles": [
? ? ? ? "node_modules/bootstrap/dist/css/bootstrap.css",
? ? ? ? "node_modules/font-awesome/css/font-awesome.css",
? ? ? ? "node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
? ? ? ? "node_modules/ng-zorro-antd/src/ng-zorro-antd.less",
? ? ? ? "src/styles.scss",
? ? ? ? "src/animate.css"
? ? ? ]
}
? },
? "lint": {
? ? "builder": "@angular-devkit/build-angular:tslint",
? ? "options": {
? ? ? "tsConfig": [
? ? ? ? "src/tsconfig.app.json",
? ? ? ? "src/tsconfig.spec.json"
? ? ? ],
? ? ? "exclude": [
? ? ? ? "**/node_modules/**"
? ? ? ]
}
? }
}