Shared Assets in a Monorepo setup

Hi,
Please, I’d like to know if it is possible to have a monorepo setup with share assets (images, css files etc.).

Currently, it seems once a subfolder is deployed as “Publish directory”, the folders/assets above it cannot be referenced.

Imagine a setup similar to the one posted to Netlify’s blog.

repo/site/www.company.com
repo/site/app.company.com
repo/site/docs.company.com
repo/site/assets

_
__

I am using Jekyll for this setup. Any help is kindly appreciated. Thank you!

Great writeup, @tunjos, and welcome to our community!

Our deploys do indeed publish ONLY the publish directory you have configured (or the root of your repo / your base setting, if none is specified). So to publish “many directories”, they’d need to be subdirectories of your app and would need to be in the publish directory.

You could try something like this in your build pipeline that may help adjust the organization, but I suspect it would be a problem for other reasons - e.g. jekyll would reference the wrong paths for such assets in its generated html.

jekyll build && mv ../assets assets ...

I guess you could also deploy the shared assets in a 4th site and refer to them by name (https://othersite/assets/X) from every one of the 3 sites sharing access?

Finally, you could proxy between the sites - or proxy the assets folder between sites - to deploy only one copy of it. This could work with or without that 4th dedicated site I mention, and some guidance on that workflow (think of your “separate monorepo-built sites” here as being “separate repos” to see the direct application):

One more note - if you do end up copying the assets to each of your 3 sites’ publish directories as you build, this will not meaningfully impact your build times - we will not “re-upload” copies of unchanged files from a prior build EVEN ON ANOTHER SITE - so you won’t have to pay the time for uploading/processing repeatedly (just on first upload).

Hello @fool,
Thank you for the feedback.

Regarding your first suggestion, I think it would be more like:
jekyll build && mv ../assets _site/assets ..., since _site is the default Jekyll output directory.

I do think this would work, as the URLs would simply reference the non-existent _site/assets path from the start. However, I’ll be unable to seamlessly do a jekyll serve locally, without doing the additional move step.

The second option would kinda interfere with the local preview. Same for the proxy suggestion/option.

What I currently do is to use a sync.sh script to copy all assets from the main site to other subsites locally before doing a commit. e.g.
cp -a www.company.com/assets/. app.company.com/assets
cp -a www.company.com/assets/. docs.company.com/assets

And I always make sure that any edit to an asset is done on the main site so that it can be synced.

I do think your first option would be very sufficient for now though. Thank you very much.
The final tip helpful too.