Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main.js: Combine presets/registers in addons field #9246

Merged
merged 10 commits into from
Dec 31, 2019

Conversation

shilman
Copy link
Member

@shilman shilman commented Dec 25, 2019

Issue: #9245

What I did

First implementation of a combined addons entry in main.js

Before: Presets are a “superset” of addons

  • Addons are packages that extend Storybook’s UI (but not always, e.g. Storyshots). They sometimes use a mechanism called presets to configure storybook and/or register themselves (e.g. Docs)
  • Presets are both packages that configure Storybook and also a mechanism by which addons can configure Storybook.
module.exports = {
  presets: ['@storybook/addon-docs/preset'],
  addons: ['@storybook/addon-actions/register']
}

After: Addons are a “superset” of presets

  • Addons are packages that extend Storybook in various ways (UI, binaries, libraries, configurations)
  • Presets are THE mechanism by which addons configure Storybook, including registering themselves with Storybook.
module.exports = {
  addons: [
    '@storybook/addon-docs',
    '@storybook/addon-actions'
  ]
}

Also the following works if you want to be more precise / backwards compatible:

module.exports = {
  addons: [
    '@storybook/addon-docs/preset',
    '@storybook/addon-actions/register'
  ]
}

Assumptions:

  • Addon registration always ends in /register, e.g. @storybook/addon-actions/register. I've checked and this seems to be the case.
  • If users want an addons function, they can use managerEntries instead.

How to test

See updated examples: official-storybook, vue-kitchen-sink, cra-ts-kitchen-sink

@vercel
Copy link

vercel bot commented Dec 25, 2019

This pull request is being automatically deployed with ZEIT Now (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://zeit.co/storybook/monorepo/kd123dzt9
✅ Preview: https://monorepo-git-core-addon-preset-consolidation.storybook.now.sh

@shilman shilman changed the title Main.js config: Combine presets and register entries in addons field Main.js config: Combine presets/registers in addons field Dec 30, 2019
@shilman shilman changed the title Main.js config: Combine presets/registers in addons field Main.js: Combine presets/registers in addons field Dec 30, 2019
@shilman shilman added core maintenance User-facing maintenance tasks labels Dec 30, 2019
@shilman
Copy link
Member Author

shilman commented Dec 31, 2019

self-merging @tmeasday @ndelangen

@shilman shilman merged commit 078366b into next Dec 31, 2019
@shilman shilman deleted the core/addon-preset-consolidation branch December 31, 2019 08:14
meirish added a commit to hashicorp/structure that referenced this pull request Jan 2, 2020
meirish added a commit to hashicorp/structure that referenced this pull request Jan 21, 2020
* add packages and config for storybook

* add story blueprint and test

* update storybook so we can use addon docs auto-generation

* use new more succinct main.js config for storybook - see storybookjs/storybook#9246

* add generated preview-head to gitignore

* add top-level storybook:build yarn script

* add storybook output dir to gitignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant