Open abiriadev opened 2 months ago
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 main.js
and into those parts of the code. Fixing this is a larger architectural issue.
In the meantime, please use the recommended story suffix and you won't have any problems.
@shilman cc @valentinpalkovic
Fixing this is a larger architectural issue.
I totally understand that it would be hard to refactor every hardcoded part of the entire codebase!
In the meantime, please use the recommended story suffix and you won't have any problems.
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.https://github.com/storybookjs/storybook/blob/479b8e919fccf12d3def4470d455682bb3965c45/code/lib/csf-plugin/src/index.ts#L9
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).https://github.com/storybookjs/storybook/blob/479b8e919fccf12d3def4470d455682bb3965c45/code/lib/csf-tools/src/enrichCsf.ts#L7-L10
https://github.com/storybookjs/storybook/blob/479b8e919fccf12d3def4470d455682bb3965c45/code/lib/csf-plugin/src/index.ts#L16-L18
But it would be ideal for
addon-docs
to automatically extractstories
field frommain.ts
, since@storybook/addon-essentials
should work with zero-config.