Skip to content

Since Nx 19.4, @nx/vite/plugin dosn't generate serve target even if there is an eplicit server target in the vite config #27370

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

Closed
1 of 4 tasks
beaussan opened this issue Aug 10, 2024 · 1 comment · Fixed by #27507
Assignees
Labels
outdated scope: bundlers Issues related to webpack, rollup type: bug

Comments

@beaussan
Copy link
Contributor

beaussan commented Aug 10, 2024

Current Behavior

@nx/vite/plugin will only create serve target on a vite project when there is not a build.lib target, even if there is a serve config present in the vite.config.ts. This change was introduced by #26420

Expected Behavior

@nx/vite/plugin infers correctly that the project has a serve target, and thus create them on the graph

GitHub Repo

https://github.com/beaussan/repro-vite-lib-serve

Steps to Reproduce

  1. Create a vite project via @nx/react:library for ex
  2. Update vite.config.ts to add a serve target
  3. The graph should contains the serve / serve static targets

Nx Report

NX   Report complete - copy this into the issue template

Node           : 20.11.1
OS             : darwin-arm64
Native Target  : aarch64-macos
yarn           : 1.22.21

nx                 : 19.5.7
@nx/js             : 19.5.7
@nx/jest           : 19.5.7
@nx/linter         : 19.5.7
@nx/eslint         : 19.5.7
@nx/workspace      : 19.5.7
@nx/devkit         : 19.5.7
@nx/eslint-plugin  : 19.5.7
@nx/react          : 19.5.7
@nrwl/tao          : 19.5.7
@nx/vite           : 19.5.7
@nx/web            : 19.5.7
typescript         : 5.5.4
---------------------------------------
Registered Plugins:
@nx/vite/plugin
@nx/eslint/plugin
@nx/jest/plugin

Done in 1.74s.

Failure Logs

No response

Package Manager Version

No response

Operating System

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

Additional Information

I see two way to fix the issue:

  • Detect when there is a serve config on a build library
  • Add a flag to the generator options to force creating a serve target for every vite project
@FrozenPandaz FrozenPandaz added the scope: bundlers Issues related to webpack, rollup label Aug 12, 2024
Coly010 added a commit that referenced this issue Aug 19, 2024
FrozenPandaz pushed a commit that referenced this issue Aug 21, 2024

Verified

This commit was signed with the committer’s verified signature.
FrozenPandaz Jason Jean
…27370 (#27507)

<!-- 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 -->
Vite Plugin was originally only checking if the `lib` option was defined
in a vite config, and using that to avoid inferring serve targets.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Some libraries may still need a serve target, and if they have a server
config defined, the serve target should be inferred

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

Fixes #27370

(cherry picked from commit 08fc13d)
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: bundlers Issues related to webpack, rollup type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants