Storybook Integration
Current status: Alpha/Experimental
Cloudpack provides integration with Storybook v7 + React for component development and testing.
You can see an example of this integration in the storybook-mock app.
Instructions
Install dependencies. You can use either npm or yarn, but I will be using yarn in this example.
bashyarn add -D @ms-cloudpack/storybook-react @ms-cloudpack/cliAdd the following script to
package.json:json"cloudpack:init": "cloudpack init"and I am assuming you already have a script that looks something like this:
json"storybook": "storybook dev -p 6006"Run
yarn cloudpack:initfrom the root of your repo and hopefully there are no errors.Update the
frameworkfield of your.storybook/main.ts(or.js):jsframework: { name: '@ms-cloudpack/storybook-react', options: {}, },The framework
@ms-cloudpack/storybook-reactinternally uses the custom Cloudpack builder@ms-cloudpack/storybook-builderand the renderer@storybook/react.Add a
cloudpack.config.jsonfile to the root of your app, following the example of Cloudpack'sstorybook-mock/cloudpack.config.json. Be sure to change the first package setting match for the name of the app you are using and include the storybook plugins in your app.You can then run
yarn storybookand it should work as expected.
Notable limitations
See also: parent GitHub issue for improving Storybook support.
- Only Storybook 7 is supported (GitHub issue for Storybook 8+ support)
cloudpack initdoesn't fully work with Storybook- Currently, all stories must be listed individually as
exportsincloudpack.config.json(GitHub issue) - The addons, framework, and renderer aren't detected as used dependencies (workaround; GitHub issue)
- Currently, all stories must be listed individually as
- Manual fixes are required in
cloudpack.config.jsonto remove non-browser entries from storybook dependencies (workarounds instorybook-mock/cloudpack.config.json; Github issue) - Missing features:
- Storybook config options related to the bundler are ignored
.mdxsupport (you can use bundler capabilities for now; related GitHub issue)- Automating documentation using
react-docgen-typescript - Storybook Build (GitHub issue)