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

Can't forward options to @storybook/addon-docs #77

Closed
guillaumewuip opened this issue Aug 29, 2024 · 0 comments · Fixed by #78
Closed

Can't forward options to @storybook/addon-docs #77

guillaumewuip opened this issue Aug 29, 2024 · 0 comments · Fixed by #78

Comments

@guillaumewuip
Copy link
Contributor

guillaumewuip commented Aug 29, 2024

@storybook/addon-docs accepts some options. One of the main use cases is passing a custom remark plugin to support tables in markdown files. This is referenced in the Storybook documentation directly:

addons: [
    {
      name: '@storybook/addon-docs',
      options: {
        mdxPluginOptions: {
          mdxCompileOptions: {
            remarkPlugins: [remarkGfm],
          },
        },
      },
    },
],

storybook-builder-rsbuild is implemented in a way that uses @storybook/addon-docs internally to leverage its webpack config. This prevents the mdxPluginOptions customization to work, as it never reach this hidden @storybook/addon-docs usage. Could we investigate how to pass this config from the user-land storybook config deep to the addon-docs present function?

Here is something that is working (tested locally):

  1. in user-land, pass some builder options

    framework: {
      name: 'storybook-react-rsbuild',
      options: {
        docs: {
          mdxPluginOptions: {
            mdxCompileOptions: {
              remarkPlugins: [remarkGfm],
            },
          },
        },
      },
    }
  2. patch storybook-builder-rsbuild to forward those options to addon-docs

    export default async (
      options: RsbuildBuilderOptions,
    ): Promise<RsbuildConfig> => {
    -  const appliedDocsWebpack = await docsWebpack({}, options)
    +  const appliedDocsWebpack = await docsWebpack({}, {  ...options, ...options.frameworkOptions.docs  })

Would you accept a pull request doing just that? I can propose it and also update the react-18 sandbox to show some remark-gfm support if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant