Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(storybook): Allow stylePreprocessorOptions for React storybooks #9481

Merged
merged 1 commit into from Apr 1, 2022

Conversation

fantoine
Copy link
Contributor

@fantoine fantoine commented Mar 23, 2022

Current Behavior

Currently styles & stylePreprocessorOptions storybook options are automatically removed for non-Angular storybooks.

Expected Behavior

These options used to work correctly with React storybooks.
We should be able to use these options with React projects.

Related Issue(s)

Fixes #

Allow Angular AND React project to use these options in storybooks.

@nx-cloud
Copy link

nx-cloud bot commented Mar 23, 2022

☁️ Nx Cloud Report

CI ran the following commands for commit f88b6ed. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 7 targets

Sent with 💌 from NxCloud.

@vercel
Copy link

vercel bot commented Mar 23, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nrwl/nx-dev/AL37JxVS8JiZuYd3RVBcpySBH8K3
✅ Preview: Canceled

[Deployment for f88b6ed canceled]

Copy link
Collaborator

@FrozenPandaz FrozenPandaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! LGTM 🎉

@FrozenPandaz FrozenPandaz merged commit 5ddd895 into nrwl:master Apr 1, 2022
@mandarini
Copy link
Member

mandarini commented Apr 4, 2022

Hi there @sidmonta ! Thanks for your contribution! I don't see how you could have used stylePreprocessorOptions in non-Angular projects, since stylePreprocessorOptions is an Angular-builder-only option. Can you please give me an example?

If you look into the Storybook codebase, you can see that stylePreprocessorOptions appears only in the Storybook Angular builder options, and this makes sense, since it's just passing down this option to the actual Angular builder.

I may be wrong, however, and maybe somehow Storybook parses that and includes it in the React builder as well.

@fantoine
Copy link
Contributor Author

fantoine commented Apr 4, 2022

Hi @mandarini.

I can't tell you how it works under the hood, but we use it in our React storybooks (with NX 13.8.3).

We specified these options the same way you could do for Angular projects:

    "storybook": {
      "executor": "@nrwl/storybook:storybook",
      "options": {
        "uiFramework": "@storybook/react",
        "port": 4400,
        "config": {
          "configFolder": "libs/web/ui-thread/.storybook"
        },
        "stylePreprocessorOptions": {
          "includePaths": ["libs/web/ui-theme/src/lib/styles"]
        }
      },
      "configurations": {
        "ci": {
          "quiet": true
        }
      }
    },

Specifying it like this allowed us to share SASS mixins and functions.
It may be a bug in storybook lib or NX module but it's really useful. :)

Do you know an other way to realize this for React projects ?

@mandarini
Copy link
Member

Hi @fantoine ! I see, I will look into it. So, you're using this in Nx 13.8.3 and it works, but it stopped working in the latest version? Can you share a sample repository?

@mandarini
Copy link
Member

HI @fantoine , any updates on this? I really think that it's strange for stylePreprocessorOptions to have an effect on the React builder..

@fantoine
Copy link
Contributor Author

fantoine commented Apr 7, 2022

Hi @mandarini.

I reproduced our react/storybook configuration here.

In this repository you'll find:

Feel free to clone this repository and try to run storybook with nx run web-ui-theme:storybook.

It will work correctly until you remove the stylePreprocessorOptions option in project configuration.

@fantoine
Copy link
Contributor Author

Hi @mandarini. Did you check the sample repository ?

@mandarini
Copy link
Member

Hey, @fantoine , not yet, sorry. Lots of things came up :( :( I will as soon as I can

@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants