我正在尝试优化ng2-smart-table package,我们将其用作依赖项,因为我注意到它对lodash的依赖程度很大,即使它只使用lodash的一小部分
但是,在尝试让webpack bundle analyzer与他们的angular.json
workspace file一起使用时,我遇到了一些问题。
如果我只是尝试运行ng build,我会得到:
❯ ng build --statsJson
Unknown option: '--statsJson'
❯ ng build --stats-json
Unknown option: '--stats-json'
现在,该项目使用具有以下内容的angular.json
工作区文件:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"ng2-smart-table": {
"projectType": "library",
"root": "projects/ng2-smart-table",
"sourceRoot": "projects/ng2-smart-table/src",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/ng2-smart-table/tsconfig.lib.json",
"project": "projects/ng2-smart-table/ng-package.json"
}
},
...
如果我尝试将"statsJson": true
添加到选项中,则会出现此错误:
❯ ng build ng2-smart-table
Schema validation failed with the following errors:
Data path "" should NOT have additional properties(statsJson).
我怀疑这与使用@angular-devkit/build-ng-packagr:build
而不是标准@angular-devkit/build-angular:browser
的项目有关。但是,由于packagr显然不支持分析,所以我只是不知道如何生成分析文件。
答案 0 :(得分:0)
如果使用的工作区如
,则需要指定项目ng build myproject --statsJson
答案 1 :(得分:-1)
转到angular.json文件并检查“项目”部分。
"projects": {
"template": { <--- here
"projectType": "application",
"schematics": {},
然后运行ng build template --statsJson
您的情况是ng build ng2-smart-table --statsJson