Skip to content
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

How to require all stories? #373

Closed
lnmunhoz opened this issue Aug 11, 2016 · 2 comments
Closed

How to require all stories? #373

lnmunhoz opened this issue Aug 11, 2016 · 2 comments

Comments

@lnmunhoz
Copy link

lnmunhoz commented Aug 11, 2016

It is possible to require all stories using like node-glob in the config.js file?

I tried but there something wrong happening when glob tries to access my src path. Maybe I am doing something wrong, but I would like to see this working.

glob('../src/components/**/stories.js', (err, files) => {
  files.forEach(file => require(file))
})

Someone has a workaround?

@sean-clayton
Copy link

const req = require.context('../src/components/', true, /stories\.js$/)

function loadStories() {
  req.keys().forEach(req)
}

configure(loadStories, module)

That should work 😃

@lnmunhoz
Copy link
Author

Worked like a charm! Thank you @sean-clayton!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants