Skip to content
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

Vite Build Executor: Can't control output directory using a project's Vite config #29168

Open
1 of 4 tasks
wilcoxmd opened this issue Dec 3, 2024 · 0 comments
Open
1 of 4 tasks

Comments

@wilcoxmd
Copy link

wilcoxmd commented Dec 3, 2024

Current Behavior

Hi! When using the @nx/vite:build executor, I'd like to be able to set the build.outDir value in my vite.config.ts, rather than needing to specify an outputPath in our project.json or on the NX CLI. This may be the intent already, since the outputPath setting is optional.

When I try to do this and omit the outputPath configuration, an error is thrown:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:405:5)
    at validateString (node:internal/validators:162:11)
    at Object.join (node:path:1175:7)
    at joinPathFragments (<path-to-workspace>/node_modules/nx/src/utils/path.js:23:31)
    at viteBuildExecutor (<path-to-workspace>/node_modules/@nx/vite/src/executors/build/build.impl.js:45:72)
    ... rest of stack trace omitted

It looks like the issue might be with this logic, which doesn't check for the whether outputPath exists before trying to create a path using it.

Expected Behavior

If outputPath is not defined in project.json or on the NX CLI, I'd like the value I set in my Vite configuration's build.outDir setting to be used to determine the output directory.

GitHub Repo

https://github.com/wilcoxmd/vite-nx-no-outputPath

Steps to Reproduce

Reproduction steps are listed in the example repo.

Nx Report

Node           : 20.5.1
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 9.8.0

nx                 : 20.1.4
@nx/js             : 20.1.4
@nx/eslint         : 20.1.4
@nx/workspace      : 20.1.4
@nx/devkit         : 20.1.4
@nx/eslint-plugin  : 20.1.4
@nx/react          : 20.1.4
@nx/vite           : 20.1.4
@nx/web            : 20.1.4
typescript         : 5.5.4
---------------------------------------
Registered Plugins:
@nx/vite/plugin
@nx/eslint/plugin

Package Manager Version

npm --version
9.8.0

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Happy to help patch this if you can confirm whether this behavior is or isn't intentional, and provide guidance on any other considerations!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant