I'm using react-app-rewired & customize-cra to setup a multi-project monorepo with shared TypeScript code, without ejecting from create-react-app (the setup is described in this answer). The layout is like:
/my-project
|--- /frontend <-Contains the create-react-app
|--- /shared <-Contains some typescript source, used by the CRA
...
It works great locally. The only thing I'm unable to figure out is how to get it deployed to Heroku:
- If I use Git to just push the 'frontend' subdirectory (
git subtree push --prefix frontend heroku master
), the Heroku build of course fails, because it cannot find the source files in /shared - those weren't even pushed to the server. - I tried using the monorepo buildpack as described here, but the result was the same. Build failed, couldn't find source files in /shared.
- I've tried the "hacky" solution in the comment here: setting
"postinstall": "npm install --prefix frontend
in package.json. Although it seemed to build, accessing https://myap123.herokuapp.com and https://myap123.herokuapp.com/frontend yield 404. - I also tried the solution in the comment here: putting
release: cd frontend && npm install && npm run build
in the procfile. Same behavior: it seems to build, but is not accessible from the browser (404).
While there are many resources about deploying projects from a monorepo, and many others about sharing code between React & Node projects, I've been unable to find anything that actually works for both: share code, and deploy the projects that reference that code to Heroku. At this point, I'm just focused on trying to deploy the frontend.
Any help would be greatly appreciated.