Skip to content

Use ES6 export for Storybook stories #2207

Open
@interactivellama

Description

@interactivellama

.storybook/config.js:

import { configure } from ‘@storybook/react’;
configure(require.context(‘../src/’, true, /\.stories\.js$/), module);

Then the [component].stories.js file could also use a require.context and export all the files located in __examples__. This makes adding a story zero config by just adding a jsx file to a folder.

We will still want to identify which examples go on the doc site. Right now that is listed in the component.json file.

There's a code shift script for this: sb migrate storiesof-to-csf --glob "**/*.stories.js"

For more info:
https://medium.com/storybookjs/component-story-format-66f4c32366df

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions