16.0.1 monorepo support (new feature)

Hi, folks

We’ve upgraded to 16.0.1 netlify-cli version and our netlify publish command started to fail in CI because it is resolving the dist folder from the monorepo root, not from the package folder, where the netlify deploy command is run.

Folder structure of our repo:
/ - root of the repo, NOT the root of UI monorepo
/services/ui-app/ - UI monorepo root
/services/ui-app/packages/app - UI app we are building and deploying
/services/ui-app/packages/app/netlify.toml - only netlify config file we have
/services/ui-app/packages/app/dist - folder to be deployed (generated on npm run build command run)

Our one and only netlify.toml file:

  publish = "dist"
  command = "npm run build"

What was working for us before (paraphrasing and omitting steps here):

$: cd services/ui-app/packages/app
$: npx netlify deploy

All required env variables are set for GH CI envioronment.

After upgrade to 16.0.1 deploy command returns an error that dist folder is not found:

Deploy path:        .../services/ui-app/dist
Configuration path: .../services/ui-app/packages/app/netlify.toml
Error: No such directory .../services/ui-app/dist! Did you forget to run a build?

You can see that toml file is resolved correctly, but deploy path is resolved relatively to the UI monorepo root (/services/ui-app), even though command itslef is run from the corresponding package (app) folder - is this expected?

We found out about the filter argument, and tried that one (as --filter app or --filter packages/app or --filter @ourScope/app, while running command from the app package folder as well as from UI monorepo root folder, but nothing worked for us - dist folder is not resolved correctly and sometimes netlify.toml file is not resolved as well (when command is run from the monorepo root folder).

My assumption is that the case where UI monorepo root is NOT the same as git repo root hasn’t been tested. And that’s the not-so-common bucket we fall into.

At the moment we’ve fixed it by publish = "packages/app/dist" and adding --filter app flag to our netlify deploy command (however not sure if that one makes a difference).


Hi @amalitsky,

Thank you for sharing this. We’ve sent this over to the devs. For now, you’d have to use the v15 to continue deploying.

Hey, Alex

Thanks for your patience while we confirmed with our developers that change is intended. We released this change behind a major version signaling that we are performing a breaking change for existing monorepository workflows.

The rationale behind that change was that we had to streamline the local development experience with the one that exists on our CI (buildbot environment) and to not break existing buildbot workflows.

As the configuration file is always resolved relative to the base directory in monorepo setups this base directory is set to the workspace root. Consequently, all paths must now be resolved from the workspace root locally as well.

We’ve written more about the enhanced monorepo experience on Netlify in our blog and in our docs.

Let us know if that helps!

Thanks, @audrey! This helps.

As of now we are using the following configuration:

  base = "services/ui-app/packages/app"
  publish = "dist"

And looks like this is the way it should be.

We can’t run netlify deploy from the root of our monorepo though, but it does work when run from a particular package folder. And filter param is not needed in our case. Probably that’s because we don’t have a top level netlify.toml file.

Have a few questions related to the documentation. I ran across them while working on this issue itself.

Builds Config > Definitions > Publish directory states

The directory is relative to the base directory, which is root by default (/). If you specify a different base directory, it should be included in the publish directory path. For example, if your base directory is set to site, the publish directory should include the site/ prefix like so: site/public

Which sounds very confusing. Is publish relative to base directory, or has to include base path in it? I don’t think you can have it both ways. In our case, publish directory seems to be relative even when base directory is set (not /).

My second and last question is on Monorepos > Use a Netlify Configuration file section, which goes like this:

You can configure most build and deploy settings for your site using a Netlify configuration file instead of the Netlify UI. Note that the publish directory can only be set in the Netlify UI.

I don’t think that publish directory can only be set in Netlify UI. We do have it set in netlify.toml and it works just fine :grin: Maybe the author meant to say packages folder?

Yes, publish directory is relative to the base path. I think the docs tried to clear the confusion that might arise in the UI as the UI automatically appends the base path to the publish path.

We’ll try to get that reviewed. Thank you for flagging.


Hi @amalitsky, I’m a member of the Netlify Docs team. Thanks for pointing out some confusion and an area of the Monorepos content where we had mistakenly swapped in publish directory for package directory.

@hrishikesh was right in that the publish directory definition is trying to account for the UI experience as well as those who set it in the TOML file.

We made a fix to the Monorepos doc here based on your feedback. You can find the updated content here. Thanks!

1 Like

Glad to help @rstav! love the product and convenience of CLI. You are a great team and thanks for the fast turnaround!

It’s your and team call obviously, but I do feel that publish directory description in docs is confusing, because to me it sounds like it is both - relative to baseUrl and not - and that can’t be true, obviously.

Mb separate paragraph regarding interface behavior in UI would help? I don’t use UI for the setup, hence don’t really know the behavior.

Or, alternatively, sentence about how this is different when configured via toml file.

Anyway, my problem is fully resolved for a while now, thanks everybody!