{"action":"closed","issue":{"url":"https://api.github.com/repos/storybooks/storybook/issues/3695","repository_url":"https://api.github.com/repos/storybooks/storybook","labels_url":"https://api.github.com/repos/storybooks/storybook/issues/3695/labels{/name}","comments_url":"https://api.github.com/repos/storybooks/storybook/issues/3695/comments","events_url":"https://api.github.com/repos/storybooks/storybook/issues/3695/events","html_url":"https://github.com/storybooks/storybook/issues/3695","id":328438782,"node_id":"MDU6SXNzdWUzMjg0Mzg3ODI=","number":3695,"title":"Access storybook as library in iframe","user":{"login":"chrisvxd","id":985961,"node_id":"MDQ6VXNlcjk4NTk2MQ==","avatar_url":"https://avatars3.githubusercontent.com/u/985961?v=4","gravatar_id":"","url":"https://api.github.com/users/chrisvxd","html_url":"https://github.com/chrisvxd","followers_url":"https://api.github.com/users/chrisvxd/followers","following_url":"https://api.github.com/users/chrisvxd/following{/other_user}","gists_url":"https://api.github.com/users/chrisvxd/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisvxd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisvxd/subscriptions","organizations_url":"https://api.github.com/users/chrisvxd/orgs","repos_url":"https://api.github.com/users/chrisvxd/repos","events_url":"https://api.github.com/users/chrisvxd/events{/privacy}","received_events_url":"https://api.github.com/users/chrisvxd/received_events","type":"User","site_admin":false},"labels":[{"id":589411025,"node_id":"MDU6TGFiZWw1ODk0MTEwMjU=","url":"https://api.github.com/repos/storybooks/storybook/labels/babel%20/%20webpack","name":"babel / webpack","color":"fbca04","default":false},{"id":820606800,"node_id":"MDU6TGFiZWw4MjA2MDY4MDA=","url":"https://api.github.com/repos/storybooks/storybook/labels/core","name":"core","color":"f9d0c4","default":false},{"id":343576456,"node_id":"MDU6TGFiZWwzNDM1NzY0NTY=","url":"https://api.github.com/repos/storybooks/storybook/labels/feature%20request","name":"feature request","color":"9B58D8","default":false},{"id":735933332,"node_id":"MDU6TGFiZWw3MzU5MzMzMzI=","url":"https://api.github.com/repos/storybooks/storybook/labels/inactive","name":"inactive","color":"ffffff","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-06-01T09:06:26Z","updated_at":"2018-08-12T12:26:17Z","closed_at":"2018-08-12T12:26:17Z","author_association":"NONE","body":"### Work summary\r\n\r\nMake `getStorybook` available in the iframe, exporting `preview` as a library by default.\r\n\r\nSome tools, like [story2sketch](https://github.com/chrisvxd/story2sketch), require users to export `getStorybook` in their config to add to `preview.js`, and then override their webpack config to enable `preview` to be accessed as a library in the iframe. In story2sketch, the iframe is loaded into puppeteer and the available stories extracted (see https://github.com/chrisvxd/story2sketch/blob/chris/add-examples/src/server/getStorybook.js).\r\n\r\nThe story2sketch README instructs users override their storybook webpack config:\r\n\r\n```js\r\nmodule.exports = (storybookBaseConfig, configType) => {\r\n  const newConfig = {\r\n    ...storybookBaseConfig\r\n  };\r\n\r\n  // Add this:\r\n  // Export bundles as libraries so we can access them on page scope.\r\n  newConfig.output.library = \"[name]\";\r\n\r\n  return newConfig;\r\n}\r\n```\r\n\r\nAnd to export `getStorybook` in their config:\r\n\r\n```js\r\nimport { getStorybook } from \"@storybook/react\";\r\n\r\n...\r\n\r\nexport { getStorybook }\r\n```\r\n\r\nIt would be a nice enhancement to move this upstream, to make the setup of tools like story2sketch simpler.\r\n\r\n### Where to start\r\n\r\nlib/core/src/server/config/webpack.config.prod.js\r\n\r\n### Acceptance criteria\r\n\r\n* Running `preview.getStorybook()` in the iframe will return storybook.\r\n*  Nothing breaks for existing users.\r\n\r\n### Who to contact\r\n\r\nCore storybook team, or myself (@chrisvxd) for any more info."}}
{"actor":{"display_login":"igor-dv"}}