Multiple netlify.toml files in monorepo

I’m struggling to understand the new monorepo support from only the blog post and brief paragraph in the docs.

One fundamental question I have is: does this mean we can drop different netlify.toml files in our monorepo package subdirs? The blog post doesn’t mention this, or really any other technical specifics.

The paragraph in the docs says you can configure your base dir in the netlify.toml file. But if the base dir is specified in the netlify.toml that seems to me to require that the netlify.toml file is in the monorepo root.

So I assumed that we’d still have to configure the base dir in the Netlify UI, so that the build process knew where to find the correct netlify.toml file (that is, in the monorepo package subdir).

Am I just misunderstanding this? Does the new monorepo support not permit a netlify.toml file in each website subdir? The folks in this thread seem to think it does support multiple netlify.toml files… :thinking:

It would be fantastic if the docs specifically addressed this issue, it seems fairly core to understanding the feature.

Thanks so much for working on monorepo support – that’s hugely important for us and it’s great to know it’s on your radar. Would love to see some work on the remaining issues with monorepos built with yarn workspaces worked out as well.

1 Like

I’ve confirmed that the monorepo support does in fact support multiple netlify.toml files. I also tested what would happen if you put a netlify.toml in the monorepo root and then also one in the site package subdir. I was hoping Netlify would merge the two config files, preferring the subdir one in case of duplication, but in fact, it seems to totally ignore the monorepo root one and only find or care about the one in the base directory (sub-package).

The docs around this are still pretty small and somewhat misleading. For instance they reference setting your base directory in the netlify toml – but if you’re trying to use the new monorepo support, you can’t do that – you have to set the base dir in the UI so that Netlify will go there and find the netlify.toml there and give you the benefit of skipping publishing when the subdir doesn’t change.

1 Like

You should be able to put the netlify.toml in each subdir, if the base is configured in the UI, yes.

If you have one in the root that doesn’t have base set, that should be fine. If base is set it in, and doesn’t match what’s in the UI, not sure what would happen (so, don’t set base in that netlify.toml unless you have only one netlify site, is my suggestion).

Does that help?

I will also review this feedback with our documentation team who are working specifically on the monorepo docs this sprint.

Hmm so you have monorepo, where you have folder with different sites, and you can put there different netlify.toml files, and it is working ? It is working for me, if i will set root of my deployment to that packages, but if root will be the whole repository, than it is picking up only netlify.toml in root of the whole repo :confused:

If i set base in UI to the root of monorepo repository, is it still possible to have other netlify.toml files in my subdirs ?

In my case, I need to have access to the whole monorepo while building and deploying (i have to build shared-components monorepo package locally, cause i don’t want to publish them to npm). So i need to run scripts from root package.json.

Right now, i see that i can have multiple netlify.toml files, but for any deployment i need to set base, to the folder where this specific netlify.toml sits.

I believe that should be possible. Here’s what I’d try:

  • set the base ONLY in the UI, for every site except the one that builds from root
  • set NO base in the UI on the site that builds from root
  • never set base in any toml file.

Please let me know if that doesn’t work!

1 Like