mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-20 05:02:37 +08:00
Merge pull request #54 from antoinerey/master
(docs) Add some documentation for requiring modules with require.context
This commit is contained in:
commit
92cb3fa26f
14
docs/api.md
14
docs/api.md
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user