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

Allow passing @storybook/addon-docs options via framework options #78

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

guillaumewuip
Copy link
Contributor

Fixes #77

/**
* @storybook/addon-docs options
*/
addonDocs?: any
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't find a way to do better than this given the typings of @storybook/addon-docs/dist/preset:

import { PresetProperty, Options } from 'storybook/internal/types';

declare const addons: PresetProperty<'addons'>;
declare const viteFinal: (config: any, options: Options) => Promise<any>;
declare const webpackX: any;
declare const docsX: any;
/**
 * If the user has not installed react explicitly in their project,
 * the resolvedReact preset will not be set.
 * We then set it here in addon-docs to use addon-docs's react version that always exists.
 * This is just a fallback that never overrides the existing preset,
 * but ensures that there is always a resolved react.
 */
declare const resolvedReact: (existing: any) => Promise<{
    react: any;
    reactDom: any;
    mdx: any;
}>;
declare const optimizeViteDeps: string[];

export { addons, docsX as docs, optimizeViteDeps, resolvedReact, viteFinal, webpackX as webpack };

No type export for the options directly, and thewebpack export is any, preventing us to extract it's parameters.

@fi3ework
Copy link
Member

fi3ework commented Sep 2, 2024

Thanks for the PR! Let's see if we can keep the way of Storybook's official provided. I'll update later.

@fi3ework
Copy link
Member

fi3ework commented Sep 2, 2024

Failed, I can't find a better way to implement this better than this PR. Great job.

@fi3ework fi3ework merged commit 028b3d3 into rspack-contrib:main Sep 2, 2024
3 checks passed
@fi3ework
Copy link
Member

fi3ework commented Sep 2, 2024

Thanks @guillaumewuip !

@guillaumewuip guillaumewuip deleted the addon-docs-options branch September 3, 2024 07:59
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 this pull request may close these issues.

Can't forward options to @storybook/addon-docs
2 participants