If you use the old storybook syntax with .storiesOf
, you can use the vitro codemod package to automatically migrate to new CSF syntax
For example this code
1stories2.add('story1', () => <Button label='Story 1' />)3.add('second story', () => (4<Button label='Story 2' />5))
Will be converted to
1export const Story1 = () => <Button label='Story 1' />2export const SecondStory = () => <Button label='Story 2' />
1npm i -g @vitro/codemod2vitro-codemod --help
Now you can run the codemod on your stories files
1vitro-codemod storybook 'src/**/*.story.jsx'
If you also want to rename the files you can add --rename
1vitro-codemod storybook 'src/**/*.story.jsx' --rename .story.jsx:.vitro.jsx
To only see what file would change you can pass the --dry
flag