我试图优化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显然不支持分析,我只是不知道如何生成我的分析文件。
3条答案
按热度按时间vof42yt11#
至于错误本身:根据Angular CLI docs,
--stats-json
选项不能用于库项目类型。该命令可用于生成“application”或“library”类型的项目。用于生成library时,将调用不同的生成器,并且仅应用
ts-config
、configuration
和watch
选项。所有其他选项仅适用于生成应用程序。yacmzcpb2#
如果您使用的是工作区,
字符串
qzwqbdag3#
转到angular.json文件并检查“projects”部分。
字符串
然后运行
ng build template --statsJson
在你的情况下,它是
ng build ng2-smart-table --statsJson