• [Nx] Note for learning Nx


    Proxy configuration:

    When we have already fews applications running in the workspace, and we want to add 'api' layer for one applicatrion only, we can use tag

    ng g @nrwl/nest:app api --frontendProject=todos

    This will only allow 'todos' app to access 'api'.

    You passed --frontendProject=todos when creating the node application. What did that argument do?

    It created a proxy configuration that allows the Angular application to talk to the API in development.

    To see how it works, open angular.json and find the serve target of the todos app.

    {
      "serve": {
        "builder": "@angular-devkit/build-angular:dev-server",
        "options": {
          "browserTarget": "todos:build",
          "proxyConfig": "apps/todos/proxy.conf.json"
        },
        "configurations": {
          "production": {
            "browserTarget": "todos:build:production"
          }
        }
      }
    }

    Note the proxyConfig property.

    Now open proxy.conf.json:

    {
      "/api": {
        "target": "http://localhost:3333",
        "secure": false
      }
    }

    This configuration tells ng serve to forward all requests starting with /api to the process listening on port 3333.

    Expose the common compoennts from library:

    Sometimes, when we create library, we might forget to expose the component, this might lead to few minutes debuggin. To avoid that we can use --export tag

    ng g component todos --project=ui --export

    Running the tests:

    Run npm run affected:apps, and you should see todos printed out. The affected:apps looks at what you have changed and uses the dependency graph to figure out which apps can be affected by this change.

    Run npm run affected:libs, and you should see ui printed out. This command works similarly, but instead of printing the affected apps, it prints the affected libs.

    Running the tests which failed previously:

    npm run affected:test -- --only-failed

    Running tests in parallel to speed up:

    Some changes affect many projects in the repository. To speed up the testing of this change, pass --parallel.

    npm run affected:test -- --parallel

    About create NPM module in workspace:

    check the source: https://nx.dev/fundamentals/develop-like-google

    By default, libraries are only buildable in the context of an application.

    To be able to build a library independently, you can pass --publishable when creating it. You can then run ng build mylib to build it, and then publish the results to an NPM registry.

  • 相关阅读:
    文本框测试用例
    用Apache生产csr申请证书
    apche配置后报错(Forbidden)没有权限
    Apache+Tomcat配置方法
    从程序员到项目经理:项目经理必须懂的一些章法
    linux 常见命令20200424
    Linux如何通过命令查看日志文件的某几行(中间极几行或最后几行)
    JPA和Hibernate的关系
    SpringBoot添加webapp目录
    @NotNull, @NotEmpty和@NotBlank之间的区别是什么?
  • 原文地址:https://www.cnblogs.com/Answer1215/p/11046508.html
Copyright © 2020-2023  润新知