-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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 to import all stories files to storybook without explicitly requiring one file at a time #125
Comments
I think that's possible to do with webpack. So simply need to use it in the config.js |
Hi, I followed your advice: Assuming all your stories follow the name e.g
then this is the way to require all project's stories import { configure } from '@kadira/storybook';
function requireAll(requireContext) {
return requireContext.keys().map(requireContext);
}
function loadStories() {
requireAll(require.context("..", true, /_story\.jsx?$/));
}
configure(loadStories, module); Maybe it will be good idea to add this to the docs. Let me know if you want me to open a pull request for it. |
Yes. It should fit somewhere here - https://github.com/kadirahq/react-storybook/blob/master/docs/api.md#loading-modules |
I see its already documented there :) import { configure } from '@kadira/storybook';
const req = require.context('./', true, /Story\.js$/)
function loadStories() {
req.keys().forEach(req)
}
configure(loadStories, module); |
oops. |
Updated URL of docs if you are landing here via Google search: https://getstorybook.io/docs/react-storybook/basics/slow-start-guide#create-the-config-file |
Load config from project dir (fixes #119)
This seems to have been pulled out of the documentation now. I've been using this approach for a long time, and it still currently works. Is this an approach that is still intended to be used?
|
@philcockfield it's in the docs: https://storybooks.js.org/docs/react-storybook/basics/writing-stories/#loading-stories-dynamically maybe we should also add it to the "slow start guide"? any suggestions welcome! |
Some folks searching might find this useful for sorting all stories ignoring folder structure/hierarchy, using the options addon, and this in your config:
|
For those RN devs having this issue, according the docs the solution is: https://github.com/elderfo/react-native-storybook-loader I tried and it works Docs Reference: https://storybook.js.org/basics/writing-stories/#loading-stories-dynamically |
general setup: https://storybook.js.org/basics/guide-vue/ alpha fix: storybookjs/storybook#3044 multi stories: storybookjs/storybook#125
it would be nice to add to the storybook config an option to require all story files that matches a specific file name pattern like *.storie.js - in a similar way that test runners are loading all test files in a projects
The text was updated successfully, but these errors were encountered: