Issue
I have a Nest project set up in monorepo mode. However, when I run yarn build, Nest only puts the root app in the dist
folder. Here's when my project structure looks like:
.
└── cloud-kruser-backend
├── apps
│ ├── root-app
│ │ ├── src
│ │ └── test
│ └── hello
│ ├── src
│ └── test
└── dist
└── apps
└── root-app
After running yarn build
I would expect dist
to have both root-app
and hello
.
Here are the relevant config files:
./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"
}
}
}
}
./apps/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"]
}
./apps/hello/tsconfig.app.json
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"declaration": false,
"outDir": "../../dist/apps/hello"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
}
Solution
nest build
, like nest start
will inherently only run on the main app. If you need to build another app as well, you need to use nest build <app-name>
, e.g. nest build hello
Answered By - Jay McDoniel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.