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

Add rake task to watch for Ruby changes and trigger Storybook hot reloading #3

Open
jonspalmer opened this issue Apr 13, 2020 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@jonspalmer
Copy link
Owner

In development mode we'd like to trigger Storybook to hot reload new story definitions if the underlying Rails code changes. In particular we'd like to catch:

  1. Changes to the Ruby Stories
  2. Changes to the ViewComponents
  3. Change to the VewComponent views

The good news is Storybook is smart enough to reload of the stories.json file changes. We just need to make that happen.

Using something like https://github.com/guard/listen seems pretty straight forward. Catching the first case is the easiest. The other cases are a bit more tricky. The question is can we target the JSON recompilation for only the necessary files. While it might be likely that by naming convention Story files have are 1-to-1 on the components the describe we want to support mixed or other naming conventions. The problem there is knowing which Stories have dependencies on which components.
a) we could regenerate all json anytime a file changes. Might be slow with lots of components
b) interrogate the Stories files to see which components they preview and trigger writing json for the dependent ones.

@jonspalmer jonspalmer added the enhancement New feature or request label Apr 13, 2020
jonspalmer added a commit that referenced this issue Apr 13, 2020
jonspalmer added a commit that referenced this issue Apr 13, 2020
@jonspalmer jonspalmer reopened this Apr 13, 2020
@jonspalmer jonspalmer added the help wanted Extra attention is needed label Jul 13, 2021
@EricRoos
Copy link

EricRoos commented Apr 4, 2022

I am leveraging Guard livereload to accomplish this. Working really well for anyone finding this now.

https://github.com/guard/guard-livereload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants