1.0.0 • Published 5 years ago

@debuggercrafts/story-parser v1.0.0

Weekly downloads
3
License
MIT
Repository
-
Last release
5 years ago

Story Helper function to parse story files using webpack require.context api.

Format

  • storyPath Path of the story file
  • storyName Name of the story
  • DefaultStoryComponent Default story exported from the story file.

Usage

// .storybook/config.js
import { storiesOf, configure } from '@storybook/react'
import { loadStories } from '@debuggercrafts/story-parser'

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

configure(() => {
  const stories = loadStories(req)

  stories.forEach(({ storyPath, storyName, DefaultStoryComponent }) => {
    const storyRoot = storiesOf(storyPath)

    storyRoot.add(storyName, DefaultStoryComponent)
  })
}, module)