【问题标题】:nrwl/nx schematics create angular app and configure angular jsonnrwl/nx 原理图创建 Angular 应用程序并配置 Angular json
【发布时间】:2020-08-21 10:43:00
【问题描述】:

我在 nrwl/nx monorepo 工作。我的应用程序在 angular.json 中有自定义配置。例如,输出路径是定制的。现在我想编写自己的原理图,它将配置我的项目。

我的问题是,我不知道如何编写可以更改 angular.json 中的属性的示意图。 我需要帮助。

最好的祝愿。

【问题讨论】:

    标签: angular nrwl nrwl-nx angular-schematics


    【解决方案1】:

    这是通过 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));
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2019-05-21
      • 1970-01-01
      • 2020-08-29
      • 2018-05-11
      • 2019-05-23
      • 2021-08-22
      • 2018-10-30
      • 2019-04-15
      • 2021-11-15
      相关资源
      最近更新 更多