@hrishikesh@lenadavids I’ve had a chance to checkout hrishikeh’s solution, which has clarified what is going on for me. However, it seems off to have to put items that can get built into the repo. So, I have come up with this solution:
Base directory: /
Publish directory /packages/chess-game/build/
But this is the main thing:
Build command: cd packages/components && yarn build && cd ../chess-game && yarn build
With that setup, it works, and I do not have to put built things into the repo.
The first thing I wanted to check was whether, when running locally, yarn install is sufficient to get it to work. It isn’t. Locally, I still have to yarn build the components as well. So, that is what has to happen on Netlify too.
Then, the next question is, what about the doc Monorepos | Netlify Docs? I believe that doc should reflect the above.
The section Base directory versus cd seems off with regard to this case, as do the discussions regarding project structures with apps and shared components in the same monorepo. I’m not sure exactly when it’s right to give the root as the base directory combined with cd, versus setting it to the directory with your app. But the cd approach with builds for all the shared components seems necessary for projects with the app(s)/shared-component(s) structure.
I’m thinking that the rule of thumb might be if the package doesn’t depend on other packages in your monorepo, then use the package dir as the base dir, otherwise you need the cd approach. What do you think?
I think your last reply sums it up pretty much correctly, at least from what I’ve understood from all the experimenting and there seems to be a reasonable explanation for that.
When you set base directory to your website’s folder, Netlify won’t be reading any of the folders above that level, and thus, would fail to install the component from the repo (as npm will search for it in the registry and it won’t exist there - an important reason to have a unique name for the package). However when you set the base directory to the room and use workspaces, npm or yarn is able to read the entire repo, all of the package.jsons within it and manage the module resolution accordingly. So once all the modules are installed, you can cd into the directory you want to build and that should do it.
IMO this should be the default behavior, or at least there should be a simple option to disable the context isolation during builds in a monorepo. It’s fairly common for sites in monorepos to import other packages in the monorepo, after all.
If i put all dependencies in feanaro’s package .json =>
Why i use monorepo ? I delete 3 GB for putting react package and co on commun workspace lol.
Are you sure Netlify support monorepo ? (including commun package.json)
Proposition - Legacy
It will be more helpfull at least Netlify made special attribute on package.json that override package.json’s dependencies and then make all operations …
Anyway
can you help with any clue ?
I dont have many good alternative : /
I have already test a lot with “build command”
=> have issue with shared components packages, don’t “find” it (publish and available on npm, maybe on conflict with reference on tsconfig.json).
Maybe there is a config file for solving this but want esiest solution as possible,
Netlify have error when build, but locally not, so … there is a solution for sending “build folder” as “already build” ?
maybe not “modern” and too legacy but garentee to publish something and avoid weird behaviour…
Not quite sure where you’re trying to go here but may I recommend that you read through our monorepo docs and try to set things from the beginning on a new site perhaps?
I found that but i dont really know how it helps me : /
the doc dont me help at all … dont know what to do (i read many times …).
I have already my “workspaces”.
“app” folder contain all apps
“package” folder contain shared components.
I will test that but I guess i will have the same error …
[build]
# Directory to change to before starting a build.
# This is where we will look for package.json/.nvmrc/etc.
base = "/"
# Directory (relative to root of your repo) that contains the deploy-ready
# HTML files and assets generated by the build. If a base directory has
# been specified, include it in the publish directory path.
publish = "./build"
# Default build command.
command = "yarn run build"
# The following redirect is intended for use with most SPAs that handle routing internally.
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
I would suggest that to activate our monorepo support, you’d use a base directory of apps/ or packages/ - depending on what site you are trying to build. The usual way that folks lay out their monorepos is to “group” all the assets for the site into a subdirectory - and then start their build there (which the base setting does! - so if you have many sites under apps/ - you’d set apps/site1 or something like that as base).
Please let us know how it goes in that configuration!