Skip to content

Excluding stories from production #31574

Answered by JReinhold
unional asked this question in Help
Discussion options

You must be logged in to vote

There is not, however a viable workaround is to depend on environment variables that control which stories are matched in the glob pattern configured in the main configuration. We've used that a couple of places in the past, but you can see one place where we do this today:

  1. make stories glob conditional on an env var: https://github.com/storybookjs/addon-svelte-csf/blob/b5c9e39a2079b83bad002d65503e9c70c0d0fc70/.storybook/main.ts#L3-L17
  2. Set the env var when building the Storybook: https://github.com/storybookjs/addon-svelte-csf/blob/main/.github/workflows/chromatic.yml#L46-L47

Essentially, in your main.ts you conditionally apply story globs based on some env var:

export default {
  stories

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@unional
Comment options

Answer selected by unional
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants