Deploying Storybook

Hi! I’m a bif fan of netflify, but i’m struggling with an issue, maybe we could all resolve it.

I have a react-webpack project hidrated by a function (apollo-lambda-server) and is great, but i’m trying to deploy also my storybook (react components library), so the designers can play with it.

It is just an npm run build-storybook command, so i’ve tried creating another Site and deploying it manually, but it is getting my default netlify.toml configuration and deploying the main react project build.

Is there a way to solve it? Maybe using the same site and some context? Thanks a lot.

1 Like

Tis a known issue that right now we don’t respect netlify.toml in other directories when building. You cannot successfully use netlify.toml to control either site you have hooked up to the same repo, unless they share build commands (or you don’t specify a build command in the file, specifying instead in our UI for EACH SITE).

We might deploy a change for that soon so I’ll follow up here if we do!

1 Like

Thanks a lot about that!

Any chance there has been any progress on this in the meantime?
Basically trying to do the same things and deploy storybook, next to our our regular Gatsby project

Same here: I’d like to deploy both Storybook and a NextJS site using a single repository.

I’m guessing we would need to restructure internal directories to work like a monorepo? Common configurations | Netlify Docs

Hey @wslyvh and @g-azambrano,
It’s been two years since that conversation, and there have been many many changes to how we can build- including monorepo support! I also know many of our customers deploy storybook, so should be possible :slight_smile: One way to do this might be to deploy on a branch called storybook and then set your build command for that branch within a context-specific block in the netlify.toml, like:

# netlify.toml
command = npm run build

command = npm run build-storybook

Here’s more on deploy contexts: File-based configuration | Netlify Docs

We are intending of monitoring our storybook on all branches and utilizing the power of netlify for this. As explained above, my issue is that storybook is part of the application (not possible to make a Mono repo), and we have the netlify.toml that makes the issue of deploying as a seperate site. Branches will not work either since we are running for main/master.

Any other solution?

You would have to use a weird build command in that case.

First cd to the directory of your storybook site. Build that using its build command. Then cd to the directory of your other site. Build that. Finally, copy all the files from both the builds to a separate folder and deploy that.

It’s more of a hack than a solution, but given your constraints, this seems like the only option.