Skip to content

fix(vite): prevent watch false leaking into dev server config - #36080

Merged
leosvelperez merged 2 commits into
nrwl:masterfrom
duckot13:fix/vite-watch-false-dev-server
Jul 17, 2026
Merged

fix(vite): prevent watch false leaking into dev server config#36080
leosvelperez merged 2 commits into
nrwl:masterfrom
duckot13:fix/vite-watch-false-dev-server

Conversation

@duckot13

Copy link
Copy Markdown
Contributor

Closes #36078

Current Behavior

When the Vite dev-server executor references a build target with a named configuration, the build target options can include watch: false.

That value is currently merged into the Vite dev-server config as server.watch: false.

watch: false is valid for the Nx build executor, but it is not a valid/useful value for Vite dev-server server.watch. This can cause downstream Vite plugins to fail when they expect server.watch to be unset or an object.

For example, plugins may safely initialise missing watch config with:

config.server ??= {};
config.server.watch ??= {};

However, if config.server.watch is false, the nullish assignment does not replace it. The plugin can then fail when trying to read or assign properties such as config.server.watch.ignored.

Expected Behavior

The Vite dev-server executor should not forward watch: false into Vite’s server.watch config.

This patch normalises false to undefined when resolving the watch option from the referenced build target and dev-server options.

This keeps the existing precedence behaviour while preventing the invalid boolean value from leaking into the Vite server config. Valid watch option objects continue to be passed through unchanged.

Related Issue(s)

Fixes #36078

@duckot13
duckot13 requested a review from a team as a code owner June 22, 2026 19:00
@duckot13
duckot13 requested a review from FrozenPandaz June 22, 2026 19:00
@netlify

netlify Bot commented Jun 22, 2026

Copy link
Copy Markdown

👷 Deploy request for nx-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 4891124

@netlify

netlify Bot commented Jun 22, 2026

Copy link
Copy Markdown

👷 Deploy request for nx-dev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 4891124

@nx-cloud

nx-cloud Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 4891124

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 45m 22s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 1m 1s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 18s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 5s View ↗

☁️ Nx Cloud last updated this comment at 2026-07-17 11:09:45 UTC

@nx-cloud nx-cloud Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nx Cloud has identified a flaky task in your failed CI:

Since the failure was identified as flaky, the solution is to rerun CI. Because this branch comes from a fork, it is not possible for us to push directly, but you can rerun by pushing an empty commit:

git commit --allow-empty -m "chore: trigger rerun"
git push

Nx Cloud View detailed reasoning in Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

@leosvelperez leosvelperez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@leosvelperez
leosvelperez merged commit b71cf87 into nrwl:master Jul 17, 2026
17 checks passed
FrozenPandaz pushed a commit that referenced this pull request Jul 20, 2026
Closes #36078

<!-- Please make sure you have read the submission guidelines before
posting an PR -->

<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->

<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior

When the Vite dev-server executor references a build target with a named
configuration, the build target options can include `watch: false`.

That value is currently merged into the Vite dev-server config as
`server.watch: false`.

`watch: false` is valid for the Nx build executor, but it is not a
valid/useful value for Vite dev-server `server.watch`. This can cause
downstream Vite plugins to fail when they expect `server.watch` to be
unset or an object.

For example, plugins may safely initialise missing watch config with:

```ts
config.server ??= {};
config.server.watch ??= {};
```

However, if `config.server.watch` is `false`, the nullish assignment
does not replace it. The plugin can then fail when trying to read or
assign properties such as `config.server.watch.ignored`.

## Expected Behavior

The Vite dev-server executor should not forward `watch: false` into
Vite’s `server.watch` config.

This patch normalises `false` to `undefined` when resolving the watch
option from the referenced build target and dev-server options.

This keeps the existing precedence behaviour while preventing the
invalid boolean value from leaking into the Vite server config. Valid
watch option objects continue to be passed through unchanged.

## Related Issue(s)

Fixes #36078

(cherry picked from commit b71cf87)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@nx/vite forwards watch: false from build target options to Vite dev-server server.watch

2 participants