Skip to content

Commit

Permalink
fix(storybook): set projectBuildConfig in storybook configuration gen…
Browse files Browse the repository at this point in the history
…erator
  • Loading branch information
mandarini committed Jan 17, 2022
1 parent ca2f5a3 commit 552efe2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ describe('@nrwl/storybook:configuration', () => {
},
options: {
port: 4400,
projectBuildConfig: 'test-ui-lib:build-storybook',
uiFramework: '@storybook/react',
config: {
configFolder: 'libs/test-ui-lib/.storybook',
Expand Down
15 changes: 12 additions & 3 deletions packages/storybook/src/generators/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export async function configurationGenerator(

const workspaceStorybookVersion = getCurrentWorkspaceStorybookVersion(tree);

const { projectType } = readProjectConfiguration(tree, schema.name);
const { projectType, targets } = readProjectConfiguration(tree, schema.name);

const buildable = !!targets?.build;

const initTask = await initGenerator(tree, {
uiFramework: schema.uiFramework,
Expand All @@ -59,7 +61,7 @@ export async function configurationGenerator(
configureTsProjectConfig(tree, schema);
configureTsSolutionConfig(tree, schema);
updateLintConfig(tree, schema);
addStorybookTask(tree, schema.name, schema.uiFramework);
addStorybookTask(tree, schema.name, schema.uiFramework, buildable);
if (schema.configureCypress) {
if (projectType !== 'application') {
const cypressTask = await cypressProjectGenerator(tree, {
Expand Down Expand Up @@ -300,7 +302,8 @@ function dedupe(arr: string[]) {
function addStorybookTask(
tree: Tree,
projectName: string,
uiFramework: string
uiFramework: string,
buildable: boolean
) {
const projectConfig = readProjectConfiguration(tree, projectName);
projectConfig.targets['storybook'] = {
Expand All @@ -311,6 +314,9 @@ function addStorybookTask(
config: {
configFolder: `${projectConfig.root}/.storybook`,
},
projectBuildConfig: buildable
? projectName
: `${projectName}:build-storybook`,
},
configurations: {
ci: {
Expand All @@ -327,6 +333,9 @@ function addStorybookTask(
config: {
configFolder: `${projectConfig.root}/.storybook`,
},
projectBuildConfig: buildable
? projectName
: `${projectName}:build-storybook`,
},
configurations: {
ci: {
Expand Down

0 comments on commit 552efe2

Please sign in to comment.