I'm trying to add the current version of a project (essentially the version
field from package.json
) to storybook so consumers of storybook can tell which version of the project they are looking at. However, I am finding it extremely difficult to do this, I haven't been able to find a way to do it in the config file, and haven't seen any addons that will simply show the current version of the project (other than one that is more made for showing how components have changed over versions, which isn't really what I'm after).
It's easy enough to require the package.json
file in a js file, and grab the version from there, but storybook seems pretty locked down in terms of allowing you to send any addition information to the header/sidebar.
Has anybody done anything like this before? I'd be grateful for any thoughts or theories on how this could be done. Thanks!
In Storybook, your stories render in a particular “preview” iframe (Canvas tab) inside the larger Storybook web application. The JavaScript build configuration of the preview is controlled by a webpack config, but you also may want to directly control the rendered HTML to help your stories render correctly.
Storybook is configured via a folder called . storybook , which contains various configuration files. Note that you can change the folder that Storybook uses by setting the -c flag to your start-storybook and build-storybook scripts.
Also was interested in this question. I've added to brandTitle
to .storybook/manager.js
like
import { version } from "../package.json";
addons.setConfig({
theme: create({
base: "light",
brandTitle: `My components v.${version}`
}),
});
Theming docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With