首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >NestJs:为什么monorepo模式只打包根应用程序,

NestJs:为什么monorepo模式只打包根应用程序,
EN

Stack Overflow用户
提问于 2022-09-08 15:07:10
回答 1查看 116关注 0票数 0

我有个Nest项目是以单一模式设置的。但是,当我运行纱线生成时,Nest只将根应用程序放在dist文件夹中。当我的项目结构看起来像:

代码语言:javascript
运行
复制
.
└── cloud-kruser-backend
    ├── apps
    │   ├── root-app
    │   │   ├── src
    │   │   └── test
    │   └── hello
    │       ├── src
    │       └── test
    └── dist
        └── apps
            └── root-app

在运行yarn build之后,我希望dist同时拥有root-apphello

下面是相关的配置文件:

./nest-cli.json

代码语言:javascript
运行
复制
{
  "$schema": "https://json.schemastore.org/nest-cli",
  "collection": "@nestjs/schematics",
  "sourceRoot": "apps/root-app/src",
  "monorepo": true,
  "root": "apps/root-app",
  "compilerOptions": {
    "webpack": true,
    "tsConfigPath": "apps/root-app/tsconfig.app.json"
  },
  "projects": {
    "root-app": {
      "type": "application",
      "root": "apps/root-app",
      "entryFile": "main",
      "sourceRoot": "apps/root-app/src",
      "compilerOptions": {
        "tsConfigPath": "apps/root-app/tsconfig.app.json"
      }
    },
    "hello": {
      "type": "application",
      "root": "apps/hello",
      "entryFile": "main",
      "sourceRoot": "apps/hello/src",
      "compilerOptions": {
        "tsConfigPath": "apps/hello/tsconfig.app.json"
      }
    }
  }
}

./app/root-app/tsconfig.app.json

代码语言:javascript
运行
复制
{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "declaration": false,
    "outDir": "../../dist/apps/root-app"
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
}

./app/hello/tsconfig.app.json

代码语言:javascript
运行
复制
{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "declaration": false,
    "outDir": "../../dist/apps/hello"
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-09-08 21:12:45

nest buildnest start一样,本质上只能在主应用程序上运行。如果您还需要构建另一个应用程序,则需要使用nest build <app-name>,例如nest build hello

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73651307

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档