Skip to content

fix(react): fix builder options for storybook plugin#12276

Merged
mandarini merged 1 commit into
nrwl:masterfrom
puku0x:fix-react-storybook-webpack-executor-options
Oct 21, 2022
Merged

fix(react): fix builder options for storybook plugin#12276
mandarini merged 1 commit into
nrwl:masterfrom
puku0x:fix-react-storybook-webpack-executor-options

Conversation

@puku0x
Copy link
Copy Markdown
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 #

@nx-cloud-staging
Copy link
Copy Markdown

nx-cloud-staging Bot commented Sep 28, 2022

@vercel
Copy link
Copy Markdown

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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.

2 participants