@rthames62在官方的Discord服务器上提到了他的问题,并向我提供了他的nx.json
也是他的NestJS project.json
.&
如果在座的任何人都面临这个问题,
添加@nx/nest
似乎是将全局@nx/webpack/plugin
添加到您的nx.json
中,而不是将其添加到NestJS project.json
中作为目标:
"plugins": [
{
"plugin": "@nx/webpack/plugin",
"options": {
"buildTargetName": "build",
"serveTargetName": "serve",
"previewTargetName": "preview"
}
},
{
"plugin": "@nx/eslint/plugin",
"options": {
"targetName": "lint"
}
}
]
删除@nex/webpack/plugin
项.
现在把它添加到你的NestJS project.json
:
"build": {
"executor": "@nx/webpack:webpack",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"target": "node",
"compiler": "tsc",
"outputPath": "dist/apps/YOUR NEST APP",
"main": "apps/YOUR NEST APP/src/main.ts",
"tsConfig": "apps/YOUR NEST APP/tsconfig.app.json",
"assets": ["apps/YOUR NEST APP/src/assets"],
"webpackConfig": "apps/YOUR NEST APP/webpack.config.js"
},
"target": "node",
"compiler": "tsc",
"configurations": {
"development": {
},
"production": {
}
}
}
如果您在提供NestJS应用程序时遇到问题,请将NestJS project.json
的serve
目标更改为:
"serve": {
"executor": "@nx/js:node",
"defaultConfiguration": "development",
"options": {
"buildTarget": "YOUR NEST APP:build"
},
"target": "node",
"compiler": "tsc",
"configurations": {
"development": {
"buildTarget": "YOUR NEST APP:build:development"
},
"production": {
"buildTarget": "YOUR NEST APP:build:production"
}
}
}
请记住,用NestJS应用程序的名称更改YOUR NEST APP
.
很高兴我能帮上忙.