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:
- A commit is made
- GitHub webhooks call Netlify
- Netlify pulls the repo and executes whatever command it finds in
- That triggers
npm run build
- That executes
gatsby build, which outputs to
./publicis then published to Netlify’s webspace
I have two proposed solutions:
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
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.
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?