Skip to content

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

@jonspalmer

Description

@jonspalmer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions