[英]nrwl/nx schematics create angular app and configure angular json
I'm working in a nrwl/nx monorepo.我在 nrwl/nx monorepo 工作。 My applications are having a custom configuration in angular.json.
我的应用程序在 angular.json 中具有自定义配置。 For example the output path were customized.
例如,自定义了 output 路径。 Now i want to write my own schematic, which will configure my project.
现在我想编写自己的原理图,它将配置我的项目。
My problem is, I don't know how to write a schematic which can change properties in angular.json.我的问题是,我不知道如何编写可以更改 angular.json 中的属性的原理图。 I need help.
我需要帮助。
Best wishes.最好的祝愿。
This in one option to change the output path in angular json via nx-workspace schematic:这是通过 nx-workspace 示意图更改 angular json 中的 output 路径的一个选项:
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));
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.