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
[Bug]: csf-plugin
fails to read stories with names not matching hardcoded regex
#26905
Comments
Hi @abiriadev Thank you for reporting the issue! Would you be able to put a PR together? |
@valentinpalkovic There are a variety of places where we hardcode the story suffix because it's hard to get the information out of In the meantime, please use the recommended story suffix and you won't have any problems. |
I totally understand that it would be hard to refactor every hardcoded part of the entire codebase!
Regarding the "meantime," does this imply that there are plans to address this issue in the near future, perhaps by providing an API for plugins? Or is it not planned for the immediate future? If it's unplanned, I will close this issue for now. :) Thank you always for dedicating time to this awesome project! |
Describe the bug
If a user change
stories
option frommain.ts
config(https://storybook.js.org/docs/api/main-config-stories), theaddon-docs
can't detect the stories file anymore becausecsf-plugin
assumes CSF file should match with the pattern which is hardcoded, means there is no way to configure it from outside.storybook/code/lib/csf-plugin/src/index.ts
Line 9 in 479b8e9
To Reproduce
To reproduce, I simply added custom CSF patterns to
main.ts
.You can find reproduction code at here: https://github.com/abiriadev/sb-csf-plugin-regex
As a short summary, the JSDoc comment inside
*.custom-stories.ts
does not render, while the same comment inside*.stories.ts
renders without any issue.There is also Stackblitz URL for the same code:
https://stackblitz.com/github/storybookjs/sandboxes/tree/next/react-vite/default-ts/after-storybook?file=.storybook%2Fmain.ts
System
Additional context
A quickfix I can currently come up with is, to add
stories
field toEnrichCsfOptions
type and use that value instead ofSTORIES_REGEX
(or useSTORIES_REGEX
as a fallback).storybook/code/lib/csf-tools/src/enrichCsf.ts
Lines 7 to 10 in 479b8e9
storybook/code/lib/csf-plugin/src/index.ts
Lines 16 to 18 in 479b8e9
But it would be ideal for
addon-docs
to automatically extractstories
field frommain.ts
, since@storybook/addon-essentials
should work with zero-config.The text was updated successfully, but these errors were encountered: