Angular universal:如何在多配置项目中预渲染 routesFile

问题描述 投票:0回答:0

Angular universal:如何在多配置项目中预渲染 routesFile

我有一个有多个配置的角度项目

我使用命令安装了express-engine

`ng add @nguniversal/express-engine`

我还更新了 angular.json 文件中的预渲染部分,为我拥有的多个配置配置预渲染

但是当运行命令以使用

预渲染路由时

ng run TMS:prerender:local-taxica

我遇到以下错误

An unhandled exception occurred: Configuration 'local-taxica' is not set in the workspace.
    See "C:\Users\Systems\AppData\Local\Temp\ng-sIkcAL\angular-errors.log" for further details.

日志文件输出如下:-

    [error] Error: Configuration 'local-taxica' is not set in the workspace.
        at Object.getOptions (C:\Users\Systems\source\repos\TMS-Abp4\angular-public-booking\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js:47:31)
        at WorkspaceNodeModulesArchitectHost.getOptionsForTarget (C:\Users\Systems\source\repos\TMS-Abp4\angular-public-booking\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js:126:49)
        at async Promise.all (index 1)

这是预渲染部分的样子

        "prerender": {
          "builder": "@nguniversal/builders:prerender",
          "options": {
            "browserTarget": "TMS:build:production",
            "serverTarget": "TMS:server:production",
            "routesFile": "src/routes-files/local-taxica.txt"
          },
          "configurations": {
            "production": {
              "browserTarget": "TMS:build:production",
              "serverTarget": "TMS:server:production"
            },
             
             ...

            "local-taxica": {
              "browserTarget": "TMS:build:local-taxica",
              "serverTarget": "TMS:server:local-taxica"
            },

            . . .
          }
        }

FYR 还包括我所拥有的文件的完整副本,以备您需要它们来定位问题

https://abatchi.com/downloads/angular-changes/angular.json https://abatchi.com/downloads/angular-changes/package.json

我还为 local-taxica 制作了一个环境文件,这是它的副本 https://abatchi.com/downloads/angular-changes/environment.local-taxica.ts

我尝试了很多事情并解决了一些问题,直到我遇到这个问题,但我所做的一切似乎都与这种确切情况无关

angular angular-universal multi-configuration pre-rendering
© www.soinside.com 2019 - 2024. All rights reserved.