storybook
storybook copied to clipboard
[Bug]: [7.0.0-beta.20]: Unable to change story loading globing parttern for something else than `stories`
Describe the bug
Trying to update the story loading configuration with a globing pattern that doesn't contain the keyword stories
.
After updating that configuration, Storybook won't start and results into the following error:
Error: No matching story indexer found for `src/components/storybook-example/ExampleButton.[customName].tsx`
To Reproduce
Based on the following configuration that is working :
├── .storybook
│ └── main.ts
├── src
├── └── storybook-example
└─────── └── ExampleButton.stories.tsx
// .storybook/main.ts
import { ConfigEnv, mergeConfig } from 'vite';
import svgr from 'vite-plugin-svgr';
import { aliases } from '../src/aliases';
export default {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(jsx|tsx)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-interactions'],
framework: {
name: '@storybook/react-vite',
options: {},
},
docs: {
autodocs: 'tag',
},
async viteFinal(config: ConfigEnv) {
return mergeConfig(config, {
plugins: [svgr()],
});
},
};
- Update the
stories
entry for something different, like follow:
stories: ['../src/**/*.mdx', '../src/**/*.storiestest.@(jsx|tsx)'],
-
Rename
ExampleButton.stories.tsx
toExampleButton.storiestest.tsx
-
Restart Storybook and the following error will appear:
Error: No matching story indexer found for /Users/xxx/Documents/myproject/apps/client/src/components/storybook-example/ExampleButton.storiestest.tsx
at StoryIndexGenerator.extractStories (/Users/xxx/Documents/myproject/node_modules/.pnpm/@[email protected]/node_modules/@storybook/core-server/dist/index.js:10:10111)
System
MacOS Monterey 12.5.1
pnpm version 7.17.1
Additional context
- The project is a monorepo using
pnpm
and its workspaces features. - Tried to clear the
node_modules/.cache
folder after updating the configuration.
This is the desired behavior. We use the file extension to determine the loading behavior of the file, e.g. .stories.ts
are handled differently from .stories.js
/.mdx
/.stories.svelte
. I think what's missing here is documentation on how to customize the indexing behavior for .storiestest.tsx
. WDYT @jonniebigodes ?
Thanks for your quick answer. Maybe my description was a bit ambiguous. I didn't want to talk about extensions but more about the file sufix before them. For example, I'd like storybook to look for [file].whatever.ts
rather than [file].stories.ts
.
Notice that this change (as described above) was working properly before the latest beta version.
@shilman any chance to reconsider that as a bug? 😃
@shilman & @jonniebigodes I can take over this docs task. I already know of the issue and wrote about it @ https://sheriffmoose.medium.com/storybook-markdown-docs-not-mdx-part-2-757463fcad84