Skip to content

Commit

Permalink
Merge pull request #54 from antoinerey/master
Browse files Browse the repository at this point in the history
(docs) Add some documentation for requiring modules with require.context
  • Loading branch information
arunoda committed Apr 5, 2016
2 parents a5fbaa4 + 50f7def commit 92cb3fa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ function loadStories() {
configure(loadStories, module);
```

Or, if you prefer to keep your stories close to your components, and use a convention to name them (i.e. `buttonStory.js`), you can require them like this:

```js
import { configure } from '@kadira/storybook';

const req = require.context('./', true, /Story\.js$/)

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

configure(loadStories, module);
```

### Load Common CSS Files

Sometimes your app has some common CSS files, so this is the best place to load them. In our Redux to-do example, we load todomvc CSS like this:
Expand Down

0 comments on commit 92cb3fa

Please sign in to comment.