Skip to content

Commit

Permalink
fix(storybook): use target project instead of default unless otherwis…
Browse files Browse the repository at this point in the history
…e specified
  • Loading branch information
mandarini committed Jan 12, 2022
1 parent ffd5033 commit 0eb0e7d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/default/api-storybook/executors/storybook.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ Type: `array`

Directory where to load static files from, array of strings

### useDefaultProject

Default: `false`

Type: `boolean`

Will use the default project as specified in the workspace configuration.

### watch

Default: `true`
Expand Down
5 changes: 5 additions & 0 deletions packages/storybook/src/executors/storybook/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
"type": "boolean",
"description": "Suppress verbose build output.",
"default": true
},
"useDefaultProject": {
"type": "boolean",
"description": "Will use the default project as specified in the workspace configuration.",
"default": false
}
},
"required": ["uiFramework", "config"]
Expand Down
16 changes: 16 additions & 0 deletions packages/storybook/src/executors/storybook/storybook.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface StorybookExecutorOptions extends CommonNxStorybookConfig {
staticDir?: string[];
watch?: boolean;
docsMode?: boolean;
useDefaultProject?: boolean;
}

export default async function* storybookExecutor(
Expand All @@ -26,6 +27,21 @@ export default async function* storybookExecutor(
) {
let frameworkPath = getStorybookFrameworkPath(options.uiFramework);

if (
!options.useDefaultProject &&
context.projectName &&
options.uiFramework === '@storybook/angular'
) {
const buildable =
!!context?.workspace?.projects?.[context.projectName]?.targets?.build;
options = {
...options,
projectBuildConfig: `${context.projectName}${
buildable ? '' : ':build-storybook'
}`,
};
}

const frameworkOptions = (await import(frameworkPath)).default;
const option = storybookOptionMapper(options, frameworkOptions, context);

Expand Down

0 comments on commit 0eb0e7d

Please sign in to comment.