我有个Nest项目是以单一模式设置的。但是,当我运行纱线生成时,Nest只将根应用程序放在dist
文件夹中。当我的项目结构看起来像:
.
└── cloud-kruser-backend
├── apps
│ ├── root-app
│ │ ├── src
│ │ └── test
│ └── hello
│ ├── src
│ └── test
└── dist
└── apps
└── root-app
在运行yarn build
之后,我希望dist
同时拥有root-app
和hello
。
下面是相关的配置文件:
./nest-cli.json
{
"$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
{
"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
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"declaration": false,
"outDir": "../../dist/apps/hello"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
}
发布于 2022-09-08 21:12:45
nest build
和nest start
一样,本质上只能在主应用程序上运行。如果您还需要构建另一个应用程序,则需要使用nest build <app-name>
,例如nest build hello
https://stackoverflow.com/questions/73651307
复制相似问题