Is it possible to rebuild only when changes are done to the subdirectory?

My project uses Next.js on the frontend and Sanity.io for the backend. For convenience, I have added both of them in the same Git repository with subdirectories for each.

Saltt
├── next
│   └── package.json
└── sanity
    └── package.json

They have been deployed on Netlify as separate sites with the respective base subdirectory. Now, I am starting to see that it might be troublesome. If I make a change to the Next subdirectory, it triggers a build in the Sanity site as well unnecessarily. Even if I lock publishes on the Sanity site, it still creates a build, which is exhausting my build minutes.

I am aware that this issue can be easily solved by having the two subdirectories are two separate Git repositories. But, is there any way I can keep the same Git structure and avoid wasting my build minutes?

Did you try this: