phoenix_storybook icon indicating copy to clipboard operation
phoenix_storybook copied to clipboard

add the option to only add and build storybook in development

Open tcoopman opened this issue 1 year ago • 6 comments

see discussion here: https://elixirforum.com/t/phoenix-storybook-a-storybook-like-ui-interface-for-phoenix-components/48890/52?u=tcoopman

For me the reason is that I want to use storybook for a project that is not open source and doesn't share it's components. Here storybook is still a great way of showing all the possible components and creating a great style guide.

tcoopman avatar Feb 27 '23 14:02 tcoopman

Hey Thomas, 6 months later, here I am! 🤪 Do you think these two setting tweaks would be enough?

  1. In router.ex, mount the storybook only in dev.
if Application.compile_env!(:my_app, :env) == :dev do
  live_storybook "/dev/storybook", [...]
end
  1. In the application's storybook.ex file, set the story compilation_mode to :lazy, so that stories are only compiled when used (ie. never in production)

WDYT?

cblavier avatar Oct 10 '23 16:10 cblavier

I'll try to have a look at it sooner than in 6 months 😂

The router trick I'm already using but the lazy compiling looks useful. I'll try it out!

tcoopman avatar Oct 10 '23 16:10 tcoopman

ok, I just set myself a reminder to come back here by April 10, 2024

cblavier avatar Oct 10 '23 16:10 cblavier

Just a 👍 for this (timely since your reminder date is in 5 days). Storybook compilation adds about 1 minute to all of our CI runs, and as this is just wasted time and expense we'd love to have a way to avoid this. Thanks.

neilberkman avatar Apr 05 '24 15:04 neilberkman

To echo on @neilberkman 's comment, we tried the suggested steps and compilation_mode: :lazy helps in cutting the number of compiled assets. However, as the doc states, we still compile .index.exs, ideally we wouldn't.

In our case, we partition test, so for instance, we're compiling this file 4 times for each PR.

I think we want to be able to not start the compiler in some environments?

crova avatar Apr 05 '24 16:04 crova

The people has spoken! I'll have a look next week ;-)

cblavier avatar Apr 05 '24 16:04 cblavier