sonhanguyen / parcel-storybook

storybook powered by parceljs instead of webpack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

parcel-storybook

full storybook (preview + manager including addons!) bundled by parceljs instead of webpack

features (thanks to parceljs :) )

  1. zero config react + typescript support (no babel, no webpack or any other config)
  2. glob import all stories (*.stories.ts), see ./storybook/iframe.ts
  3. fast bundling -- fast storybook preview bundling thanks to parceljs -- storybook manager prebuilt and included in git (approach used by snowpack and yarn 2 cache sharing), so no time spent to build it

usage

git clone https://github.com/vasileermicioi/parcel-storybook
cd parcel-storybook
yarn install
yarn storybook

storybook manager rebuild

if you need more addons (now only actions and knobs) you can modify ./storybook/config/main.js

yarn rebuild-manager
yarn storybook

!! don't forget to commit newly generated files !! rebuild manager only when you need to change manager config, not the preview or stories

motivation

storybook published a standalone preview powered by parceljs (see here https://github.com/storybookjs/storybook/tree/next/examples/standalone-preview) but the example is not working with the addons because the preview is inside an iframe with different origin, (see here storybookjs/storybook#8677) cross-origin requests/communication being blocked by browsers (same domain but different port is considered another origin)

running storybook with parceljs (because of it's simplicity) seems to be a popular request storybookjs/storybook#10110 storybookjs/storybook#8677 storybookjs/storybook#5975 (comment)

posible solutions

main problem is to fix cross-origin communication, I was able to solve that in 2 ways

  1. reverse proxy both the manager and the preview so they are in the same domain
  2. build static manager (how often are you changing storybook config?) and serving / watching only the preview having storybook manager as static assets

so current repo is solved using second approach

About

storybook powered by parceljs instead of webpack

License:MIT License


Languages

Language:HTML 44.8%Language:TypeScript 41.8%Language:JavaScript 13.5%