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(react): fix builder options for storybook plugin #12276

Merged

Conversation

puku0x
Copy link
Contributor

@puku0x puku0x commented Sep 28, 2022

Current Behavior

Nx + Next.js + SVGR + Storybook (storybook-addon-next) with Nx's SB plugin fails to handle assets because @nrwl/react/plugins/storybook does not pass target which is needed for @nrwl/webpack:webpack executor.

Expected Behavior

It should work with no build errors.

Related Issue(s)

Fixes #

@vercel
Copy link

vercel bot commented Sep 28, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
nx-dev ⬜️ Ignored (Inspect) Oct 21, 2022 at 9:16PM (UTC)

@mandarini
Copy link
Member

Hi there @puku0x ! I'm so sorry it's taken forever to look into this, and thank you! I'm looking into this today, I've been a bit short of time in the past couple of weeks, thanks for bearing with me!

@mandarini
Copy link
Member

Hi @puku0x ! I was just trying your fix in this repo posted here, and it does not seem to fix the issue... The error I'm getting is here. Is this the issue you were targeting to fix?

@mandarini
Copy link
Member

I'll merge this, but please let me know @puku0x if you were trying to fix that issue I linked above. I'm curious as to what's causing it and how it could be fixed, and you seem to have a better idea than me! :)

@mandarini mandarini merged commit 13c465d into nrwl:master Oct 21, 2022
@mandarini mandarini self-requested a review October 21, 2022 21:54
@puku0x puku0x deleted the fix-react-storybook-webpack-executor-options branch October 22, 2022 04:10
@puku0x
Copy link
Contributor Author

puku0x commented Oct 22, 2022

@mandarini Thank you for your comment.
This patch is originally supposed to be used with RyanClementsHax/storybook-addon-next#101 (or following workaround).

// apps/next-app/.storybook/main.js
webpackFinal: async (config, { configType }) => {
  // apply any global webpack configs that might have been specified in .storybook/main.js
  if (rootMain.webpackFinal) {
    config = await rootMain.webpackFinal(config, { configType });
  }

  // Workaround for https://github.com/RyanClementsHax/storybook-addon-next/issues/100
  config.module.rules
    .filter((rule) => rule.test && 'test.jpeg'.match(rule.test))
    .forEach((rule) => {
      if (rule.use) {
        rule.use.forEach((use) => {
          if (use.options && !use.options.filename) {
            use.options.filename = 'static/media/[path][name][ext]';
          }
        });
      }

      if (rule.generator && !rule.generator.filename) {
        rule.generator.filename = 'static/media/[path][name][ext]';
      }
    });

  return config;
},

Unfortunately, the PR was closed :(

@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 17, 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

2 participants