[Bug]: csf-plugin
fails to read stories with names not matching hardcoded regex
#26905
Labels
csf-plugin
fails to read stories with names not matching hardcoded regex
#26905
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: