Description
Current Behavior
Hi! When using the @nx/vite:build
executor and specifying the outputPath
, we've noticed that the files are not being generated inside of the workspace, but instead at the root of our repository. This is our target config:
"vite-target": {
"executor": "@nx/vite:build",
"options": {
"outputPath": "apps/web-app/public/static",
"configFile": "apps/web-app/vite.config.ts",
"generatePackageJson": false
}
},
To add a bit more context, our repo structure contains multiple monorepos inside of it, each of them stored in its own folder. The following tree serves as an example:
.
├── backend
│ └── v2
│ ├── apps
│ │ ├── api-service
│ │ └── worker
│ ├── nx.json
│ └── package.json
└── frontend
└── v2
├── apps
│ ├── web-app
│ └── admin-panel
├── nx.json
└── package.json
We've also configured frontend's build
to depend on the target shown above, so when we run pnpm build web-app
vite should run. As such we couldn't switch to inferred tasks, as we're not explicitly running that target.
The problem lies in the fact that when we build our web-app
, the vite-target
is generating the output at the root of the repo: ./apps/-web-app/public/static
instead of generating it at frontend/v2/apps/web-app/public/static
.
We're experiencing that behaviour since we upgraded both Nx and all of the dependencies from v19.3.1
to v20.7.2
. As we were experiencing that issue, we've swapped to use nx:run-command
and explicitly call vite
from there, but we'd like to stuck using the vite executor:
"vite-target": {
"executor": "nx:run-commands",
"options": {
"cwd": "apps/web-app",
"command": "vite build --config viteconfig.ts"
}
},
Expected Behavior
When outDir
is specified at the executor, I'd expect it creates the files at ${workspaceRoot}/${outDir}
path.
GitHub Repo
No response
Steps to Reproduce
- A simple repo with the structure shared above should be enough to repo the issue.
Nx Report
Node : 20.14.0
OS : darwin-arm64
Native Target : aarch64-macos
pnpm : 9.12.0
nx (global) : 21.0.3
nx : 20.7.2
@nx/js : 20.7.2
@nx/jest : 20.7.2
@nx/eslint : 20.7.2
@nx/workspace : 20.7.2
@nx/cypress : 20.7.2
@nx/eslint-plugin : 20.7.2
@nx/next : 20.7.2
@nx/react : 20.7.2
@nx/rollup : 20.7.2
@nx/storybook : 20.7.2
@nx/vite : 20.7.2
@nx/web : 20.7.2
typescript : 5.4.2
---------------------------------------
Community plugins:
@nx-tools/nx-container : 6.2.0
nx-stylelint : 18.0.0
---------------------------------------
Failure Logs
Package Manager Version
No response
Operating System
- macOS
- Linux
- Windows
- Other (Please specify)
Additional Information
Happy to add more information if needed, like the current Vite config we're using or anything else that may be of help!