feat(storybook): infer continuous tasks for storybook serve and serve-static (#30069)

## Current Behavior
The `@nx/storybook/plugin` does not set `continuous:true` for serve-like
targets.

## Expected Behavior
The plugin should correctly set `continuous: true` for `serve` and
`serve-static`.
This commit is contained in:
Colum Ferry 2025-02-18 17:41:49 +00:00 committed by Jason Jean
parent 7989e39461
commit f5e124972a
2 changed files with 9 additions and 0 deletions

View File

@ -97,11 +97,13 @@ describe('@nx/storybook/plugin', () => {
}, },
"serve-storybook": { "serve-storybook": {
"command": "storybook dev", "command": "storybook dev",
"continuous": true,
"options": { "options": {
"cwd": "my-app", "cwd": "my-app",
}, },
}, },
"static-storybook": { "static-storybook": {
"continuous": true,
"executor": "@nx/web:file-server", "executor": "@nx/web:file-server",
"options": { "options": {
"buildTarget": "build-storybook", "buildTarget": "build-storybook",
@ -175,6 +177,7 @@ describe('@nx/storybook/plugin', () => {
], ],
}, },
"serve-storybook": { "serve-storybook": {
"continuous": true,
"executor": "@storybook/angular:start-storybook", "executor": "@storybook/angular:start-storybook",
"options": { "options": {
"browserTarget": "my-ng-app:build-storybook", "browserTarget": "my-ng-app:build-storybook",
@ -183,6 +186,7 @@ describe('@nx/storybook/plugin', () => {
}, },
}, },
"static-storybook": { "static-storybook": {
"continuous": true,
"executor": "@nx/web:file-server", "executor": "@nx/web:file-server",
"options": { "options": {
"buildTarget": "build-storybook", "buildTarget": "build-storybook",
@ -257,11 +261,13 @@ describe('@nx/storybook/plugin', () => {
}, },
"serve-storybook": { "serve-storybook": {
"command": "storybook dev", "command": "storybook dev",
"continuous": true,
"options": { "options": {
"cwd": "my-react-lib", "cwd": "my-react-lib",
}, },
}, },
"static-storybook": { "static-storybook": {
"continuous": true,
"executor": "@nx/web:file-server", "executor": "@nx/web:file-server",
"options": { "options": {
"buildTarget": "build-storybook", "buildTarget": "build-storybook",

View File

@ -277,6 +277,7 @@ function serveTarget(
) { ) {
if (frameworkIsAngular) { if (frameworkIsAngular) {
return { return {
continuous: true,
executor: '@storybook/angular:start-storybook', executor: '@storybook/angular:start-storybook',
options: { options: {
configDir: `${dirname(configFilePath)}`, configDir: `${dirname(configFilePath)}`,
@ -286,6 +287,7 @@ function serveTarget(
}; };
} else { } else {
return { return {
continuous: true,
command: `storybook dev`, command: `storybook dev`,
options: { cwd: projectRoot }, options: { cwd: projectRoot },
}; };
@ -311,6 +313,7 @@ function serveStaticTarget(
projectRoot: string projectRoot: string
) { ) {
const targetConfig: TargetConfiguration = { const targetConfig: TargetConfiguration = {
continuous: true,
executor: '@nx/web:file-server', executor: '@nx/web:file-server',
options: { options: {
buildTarget: `${options.buildStorybookTargetName}`, buildTarget: `${options.buildStorybookTargetName}`,