Skip to content

Conversation

nkalinov
Copy link
Contributor

Current Behavior

nx preview <app> does not enable watch mode on the build.
This used to be the case until (I think) #20367

Expected Behavior

nx preview <app> should also enable watch mode and rebuild on files change.

Related Issue(s)

FYI: I also had to apply this config change for Vite 6 to unstuck from "Rebuilding project...". Maybe it's just my project, not sure but in any case those are 2 separate issues.

Fixes #31604

@nkalinov nkalinov requested a review from a team as a code owner June 17, 2025 16:20
@nkalinov nkalinov requested a review from FrozenPandaz June 17, 2025 16:20
Copy link

vercel bot commented Jun 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
nx-dev Ready Ready Preview Oct 7, 2025 4:46pm

@nkalinov
Copy link
Contributor Author

cc @mandarini

@FrozenPandaz FrozenPandaz added the priority: medium Medium Priority (not high, not low priority) label Jun 23, 2025
Copy link
Contributor

nx-cloud bot commented Jun 27, 2025

View your CI Pipeline Execution ↗ for commit 751d8d6

Command Status Duration Result
nx affected --targets=lint,test,test-kt,build,e... ✅ Succeeded 26m 34s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 2m 15s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 6s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 6s View ↗
nx documentation ✅ Succeeded 3m 27s View ↗

☁️ Nx Cloud last updated this comment at 2025-10-08 21:06:24 UTC

@Coly010 Coly010 force-pushed the fix-vite-preview-watch-true-default branch from bfb7574 to 85e729e Compare October 7, 2025 11:05
Copy link

netlify bot commented Oct 7, 2025

‼️ Deploy request for nx-docs rejected.

Name Link
🔨 Latest commit 751d8d6

nx-cloud[bot]

This comment was marked as outdated.

Copy link
Contributor

@nx-cloud nx-cloud bot left a comment

Choose a reason for hiding this comment

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

Nx Cloud is proposing a fix for your failed CI:

We've fixed the TypeScript compilation error in the preview-server executor. The issue was using {} as the default value for the watch option when it should be a boolean true to match the ViteBuildExecutorOptions type definition.

We verified this fix by re-running vite:build-base.

diff --git a/packages/vite/src/executors/preview-server/preview-server.impl.ts b/packages/vite/src/executors/preview-server/preview-server.impl.ts
index 495c063bca..edc5315814 100644
--- a/packages/vite/src/executors/preview-server/preview-server.impl.ts
+++ b/packages/vite/src/executors/preview-server/preview-server.impl.ts
@@ -57,7 +57,7 @@ export async function* vitePreviewServerExecutor(
       ...buildTargetOptions,
       ...{
         // Enable watch mode by default for the build target.
-        watch: options.watch ?? {},
+        watch: options.watch ?? true,
       },
     });
 

Apply fix via Nx Cloud  Reject fix via Nx Cloud

Apply fix locally ↗  View interactive diff ↗


⚙️ An Nx Cloud workspace admin can disable these reviews in workspace settings.

@Coly010 Coly010 merged commit 8f8f804 into nrwl:master Oct 8, 2025
15 checks passed
FrozenPandaz pushed a commit that referenced this pull request Oct 8, 2025
…31623)

<!-- 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
<!-- This is the behavior we have today -->
`nx preview <app>` does not enable watch mode on the build.
This used to be the case until (I think)
#20367

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
`nx preview <app>` should also enable watch mode and rebuild on files
change.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

FYI: I also had to apply [this config
change](vitejs/vite#19410 (comment))
for Vite 6 to unstuck from "Rebuilding project...". Maybe it's just my
project, not sure but in any case those are 2 separate issues.

Fixes #31604

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

Labels

priority: medium Medium Priority (not high, not low priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vite preview --watch does not work anymore

4 participants