feat(vite): infer continuous tasks for dev (#30043)

## Current Behavior
The `dev`, `serve`, `preview` and `serve-static` targets inferred by the
`@nx/vite/plugin` do not infer `continuous:true` indicating to Nx that
these tasks are continuous.


## Expected Behavior
Infer `continuous: true` for the serve-like targets for Vite.
This commit is contained in:
Colum Ferry 2025-02-14 13:08:31 +00:00 committed by Jason Jean
parent 63282bc070
commit 7989e39461
3 changed files with 15 additions and 0 deletions

View File

@ -123,6 +123,7 @@ exports[`@nx/vite/plugin not root project should create nodes 1`] = `
},
"dev": {
"command": "vite",
"continuous": true,
"metadata": {
"description": "Starts Vite dev server",
"help": {
@ -143,6 +144,7 @@ exports[`@nx/vite/plugin not root project should create nodes 1`] = `
},
"my-serve": {
"command": "vite",
"continuous": true,
"metadata": {
"deprecated": "Use devTargetName instead. This option will be removed in Nx 22.",
"description": "Starts Vite dev server",
@ -164,6 +166,7 @@ exports[`@nx/vite/plugin not root project should create nodes 1`] = `
},
"preview-site": {
"command": "vite preview",
"continuous": true,
"dependsOn": [
"build-something",
],
@ -186,6 +189,7 @@ exports[`@nx/vite/plugin not root project should create nodes 1`] = `
},
},
"serve-static": {
"continuous": true,
"executor": "@nx/web:file-server",
"options": {
"buildTarget": "build-something",
@ -257,6 +261,7 @@ exports[`@nx/vite/plugin root project should create nodes 1`] = `
},
"dev": {
"command": "vite",
"continuous": true,
"metadata": {
"description": "Starts Vite dev server",
"help": {
@ -277,6 +282,7 @@ exports[`@nx/vite/plugin root project should create nodes 1`] = `
},
"preview": {
"command": "vite preview",
"continuous": true,
"dependsOn": [
"build",
],
@ -300,6 +306,7 @@ exports[`@nx/vite/plugin root project should create nodes 1`] = `
},
"serve": {
"command": "vite",
"continuous": true,
"metadata": {
"deprecated": "Use devTargetName instead. This option will be removed in Nx 22.",
"description": "Starts Vite dev server",
@ -320,6 +327,7 @@ exports[`@nx/vite/plugin root project should create nodes 1`] = `
},
},
"serve-static": {
"continuous": true,
"executor": "@nx/web:file-server",
"options": {
"buildTarget": "build",

View File

@ -455,6 +455,7 @@ describe('@nx/vite/plugin', () => {
},
"dev": {
"command": "vite",
"continuous": true,
"metadata": {
"description": "Starts Vite dev server",
"help": {
@ -475,6 +476,7 @@ describe('@nx/vite/plugin', () => {
},
"preview": {
"command": "vite preview",
"continuous": true,
"dependsOn": [
"build",
],
@ -498,6 +500,7 @@ describe('@nx/vite/plugin', () => {
},
"serve": {
"command": "vite",
"continuous": true,
"metadata": {
"deprecated": "Use devTargetName instead. This option will be removed in Nx 22.",
"description": "Starts Vite dev server",
@ -518,6 +521,7 @@ describe('@nx/vite/plugin', () => {
},
},
"serve-static": {
"continuous": true,
"executor": "@nx/web:file-server",
"options": {
"buildTarget": "build",

View File

@ -430,6 +430,7 @@ async function buildTarget(
function serveTarget(projectRoot: string, isUsingTsSolutionSetup: boolean) {
const targetConfig: TargetConfiguration = {
continuous: true,
command: `vite`,
options: {
cwd: joinPathFragments(projectRoot),
@ -457,6 +458,7 @@ function serveTarget(projectRoot: string, isUsingTsSolutionSetup: boolean) {
function previewTarget(projectRoot: string, buildTargetName) {
const targetConfig: TargetConfiguration = {
continuous: true,
command: `vite preview`,
dependsOn: [buildTargetName],
options: {
@ -521,6 +523,7 @@ function serveStaticTarget(
isUsingTsSolutionSetup: boolean
) {
const targetConfig: TargetConfiguration = {
continuous: true,
executor: '@nx/web:file-server',
options: {
buildTarget: `${options.buildTargetName}`,