NX not auto generating stories for my components

Discussão em 'Angular' iniciado por Optiq, Fevereiro 17, 2025.

  1. Optiq

    Optiq Guest

    I set up an NX repo and setup storybook. My main app and my library both have a .storybook folder an the main AppComponents of both have a story. However when I try generating a component, no story generates. I generate my components by cding my way into the folder I want to generate it in and run


    npx nx g @nx/angular:component new-component/new-component
    ​

    This generates a new folder with my component files as expected. However it doesn't generate a .stories.ts file for the components. During setup I specified "yes" when asked if I wanted stories to be automatically generated.

    I went into the main.ts file of the .storybook folders of both apps and added generateStories : true to the options object of the framework object, closed the project down and restarted it, which I do by running


    npx nx run my-project:serve
    ​

    I tried to generate a story for my new component manually by running


    npx nx g @nx/angular:component-story --componentPath="path/to/component"
    ​

    It failed telling me I needed to add the --projectPath property. I added that then it said I needed to add a --componentFileName property. It continued to complain and eventually threw an error saying


    Could not read TS file (libs/apps/ingredient-manager/main-menu/main-menu.component.ts/main-menu.component.ts.ts)
    ​

    which I don't know how it concluded to that being the path to my component because it's supposed to be


    libs/apps/ingredient-manager/main-menu/main-menu.component.ts
    ​

    so I don't know what I was entering incorrectly. But what do I need to do to just get the stories to generate upon creating a component?

    Continue reading...

Compartilhe esta Página