Adding a standalone app to a subdirectory of an existing NetlifyCMS site

I am hoping someone here can help me with a bit of Netlify architecture. This is not a support request related to my particular Netlify instance. Apologies for the long post - it’s not actually a complicated issue.


Right now I have a NetlifyCMS app built using a Gatsby template. It’s hosted on a custom domain (mysite.com). I have a completely separate React app that I now want to host in a subdirectory of my website (mysite.com/specialapp). This app has its own package.json and won’t easily integrate with the Gatsby template.

In the old days with FTP deploys this would be easy. I’d put the new app in ./specialapp and the deployment would mostly be manual. Now I have to get it to work with CICD, which introduces a problem because the CICD would have to build both the existing Gatsby app and my new app on each deploy.

Here’s my current understanding of the Netlify build process:

  1. A commit is made
  2. GitHub webhooks call Netlify
  3. Netlify pulls the repo and executes whatever command it finds in netlify.toml
  4. That triggers npm run build
  5. That executes gatsby build, which outputs to ./public
  6. ./public is then published to Netlify’s webspace

I have two proposed solutions:

Solution A:
Modify step #4 in the build process so that npm run build calls gatsby build (in the root directory) but also calls npm run build in the ./specialapp directory. That would cause the React app to build to ./specialapp/build, and I could somehow call another command to copy the contents of that to ./public/specialapp.

I am not sure if NPM scripts can event be called in sub-directories like that. But either way, I can still sense that there will be complications with this. I doubt it will be straightforward.

Solution B:
Forget all that CICD - do the building of both the Gatsby and my new React app locally, copy the build output to one location and use the Netlify CLI to publish. I could even script most of it. Maybe if I got the scripts working I could then integrate it with CICD, but for right-now I’d do it all manually and it would save me pulling my hair out.


Am I over-complicating this? What are your thoughts?

Can anyone offer advice on this? I am heavily leaning toward manually building both apps and using the Netlify CLI to publish.

Maybe I’ll script it later. I do not want to spend more time getting CICD setup than actually creating my app.

Alternatively, you could have the /specialapp on its own Netlify site, with its own CICD, and set up a proxy rewrite on your main website to retrieve the /specialapp content!

Two standalone workflows, one seamless site :slight_smile:

/specialapp/* https://your-specialapp-domain.netlify.app/:splat 200!