【发布时间】:2020-08-21 10:43:00
【问题描述】:
我在 nrwl/nx monorepo 工作。我的应用程序在 angular.json 中有自定义配置。例如,输出路径是定制的。现在我想编写自己的原理图,它将配置我的项目。
我的问题是,我不知道如何编写可以更改 angular.json 中的属性的示意图。 我需要帮助。
最好的祝愿。
【问题讨论】:
标签: angular nrwl nrwl-nx angular-schematics
我在 nrwl/nx monorepo 工作。我的应用程序在 angular.json 中有自定义配置。例如,输出路径是定制的。现在我想编写自己的原理图,它将配置我的项目。
我的问题是,我不知道如何编写可以更改 angular.json 中的属性的示意图。 我需要帮助。
最好的祝愿。
【问题讨论】:
标签: angular nrwl nrwl-nx angular-schematics
这是通过 nx-workspace 示意图更改 Angular json 中的输出路径的一个选项:
function updateOutputPath(name: string, prefix: string): Rule {
return (host: Tree) => {
const angularJson = JSON.parse(host.read('angular.json').toString());
const appOutputPath = angularJson.projects[name].architect.build;
const appPrefix = angularJson.projects[name];
appPrefix.prefix = `${name}`;
appOutputPath.options.outputPath = `dist/${prefix}/static`;
angularJson.projects[name] = prefix;
angularJson.projects[name].architect.build = appOutputPath;
host.overwrite('angular.json', JSON.stringify(angularJson));
}
}
【讨论】: