@debuggercrafts/story-parser

1.0.0 • Public • Published

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)

Readme

Keywords

Package Sidebar

Install

npm i @debuggercrafts/story-parser

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

3.15 kB

Total Files

5

Last publish

Collaborators

  • rihdus