-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any idea on how to use nestjs cli plugin with nx? #4135
Comments
I was able to solve this using #2147 (comment), Just replaced swagger with graphql as /workspace.json
/apps/api/webpack.config.js
|
I created my workspace with nx and was looking for the same issue.
in my angular.json (Since my workspace was NestJS + Angular) |
Hi! |
hi @kirillvarikow and others with this issue You should put it under the nx Like this, entire file: {
"root": "packages/backend",
"sourceRoot": "packages/backend/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nrwl/node:webpack",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/backend",
"main": "packages/backend/src/main.ts",
"tsConfig": "packages/backend/tsconfig.app.json",
"tsPlugins": [
{
"name": "@nestjs/swagger/plugin",
"options": {
"classValidatorShim": false,
"introspectComments": true
}
}
],
"assets": ["packages/backend/src/common/assets"]
},
"configurations": {
"production": {
"optimization": true,
"extractLicenses": true,
"inspect": false
}
}
},
"serve": {
"executor": "@nrwl/node:node",
"options": {
"buildTarget": "backend:build"
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/backend/**/*.ts"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/packages/backend"],
"options": {
"jestConfig": "packages/backend/jest.config.js",
"passWithNoTests": true,
"codeCoverage": true,
"coverageDirectory": "coverage/packages/backend"
}
}
},
"tags": []
} |
HI! the @nrwl/nest plugin has the nest cli built in, you just have to use the commands like this: ex: nx g @nrwl/nest:resource client --project=api Here the docs: https://nx.dev/packages/nest#nest-generators I hope it works for you! |
Is this solution for @nestjs/graphql/plugin still working for you because for me after nx ver 14 it stopped. Any help? |
Example {
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/api/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nrwl/node:webpack",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/api",
"main": "apps/api/src/main.ts",
"tsConfig": "apps/api/tsconfig.app.json",
"tsPlugins": [
"@nestjs/swagger/plugin"
],
"assets": [
"apps/api/src/assets"
],
"generatePackageJson": true
},
"configurations": {
"production": {
"optimization": true,
"extractLicenses": true,
"inspect": false,
"fileReplacements": [
{
"replace": "apps/api/src/environments/environment.ts",
"with": "apps/api/src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"executor": "@nrwl/node:node",
"options": {
"buildTarget": "api:build"
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/api/**/*.ts"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/apps/api"],
"options": {
"jestConfig": "apps/api/jest.config.ts",
"passWithNoTests": true
}
}
},
"tags": []
} |
TS plugins has been removed in the latest version of NX without any notification, so this is now broken. The only option is to use a custom webpack config, which is messy |
@dan-cooke Replace |
Yeah I found that out via opening another issue, thanks!
…On Mon, 14 Nov 2022 at 22:01, Matheus Vargem ***@***.***> wrote:
@dan-cooke <https://github.com/dan-cooke> Replace tsPlugins to
transformers now. It looks like it works the same way, just different name
—
Reply to this email directly, view it on GitHub
<#4135 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFOCQ57ZU5GZQUCNOIGAC3TWIKZCZANCNFSM4T7R55NQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
TLDR your configuration in project.json should look like this: {
"name": "project-with-swagger-plugin",
"targets": {
"build": {
"executor": "@nrwl/webpack:webpack",
"options": {
// other options
"transformers": [
// register plugins here
"@nestjs/swagger/plugin"
]
},
}
}
} Thanks @mattvgm |
Thank you @eso32 {
"name": "project-with-swagger-plugin",
"targets": {
"build": {
"executor": "@nrwl/webpack:webpack",
"options": {
// other options
"transformers": [
// register plugins here
{
"name": "@nestjs/swagger/plugin",
"options": {
"introspectComments": true
}
}
]
},
}
}
} |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
I want to use nestjs cli plugin as mentioned at https://docs.nestjs.com/graphql/cli-plugin#using-the-cli-plugin. As my nx workspace does not contain nest-cli.json, I am not sure how to use this.
Also If I manually create nest-cli.json file it seems to have no effect. At https://nx.dev/latest/node/workspace/configuration#schematics it is mentioned that we can configure options from here but I am not sure how to do it.
Can anyone help me with this please? One more thing, I could not add question here as slack link is broken on add new issue page.
The text was updated successfully, but these errors were encountered: