Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Kamau Wanyee
Kamau Wanyee

Posted on

     

TenancyForLaravel FileSystem Bootstrapper asset Gotcha

TLDR; If you are using theFileSystemBootstrapper on thearchtechx/tenancy package and also theLaravel-Vite package, update your tenancy config (tenancy.filesystem.asset_helper_tenancy) tofalse. Otherwise your generated script/style tags after building assets will be returning a tenant-scoped asset URL.

Here is the context of the problem I was facing:

I am building a multi-tenant SaaS application using this tenancy package fromTenacy for Laravel. It has a concept of tenancy bootstrappers that modifies relevant framework defaults to make the application tenant aware. TheFileSystem Bootstrapper makes the Laravelasset() helper method return tenant specific assets through aTenantAssetController.
I also replaced Laravel Mix withVite and I'm using thisLaravel Vite package to make the integration easier. The package provides@vite directive to output all the necessary asset tags in your blade file. The underlying methods use theasset() helper method from the framework. Therefore, any generated asset URL is tenant-scope if I am under a tenant aware route. I am using VueJS for templating so my page ends up not being rendered correctly.

The solution is to update a tenancy config (tenancy.filesystem.asset_tenancy_helper) tofalse. Theasset() helper revert to default. The tenancy package still providestenant_asset() helper method for tenant specific assets.

I hope this helps someone out there facing the same issue and save you time.

Top comments(6)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
marcelokazalukian profile image
marcelo-kazalukian
  • Joined
• Edited on• Edited

Hello@steekam

Thanks for this article, it helped me a lot.

Now when I use the tenant_asset() function to define a manifest file for each tenant:

<link rel="manifest" href="{{tenant_asset('manifest.json')}}">
Enter fullscreen modeExit fullscreen mode

I get a URL like this:

http://subdomain.domain.com:8000/tenancy/assets/manifest.json
Enter fullscreen modeExit fullscreen mode

Where should I put the manifest.json?

Under storage, I have storage/tenant1/app

Thanks so much.

CollapseExpand
 
steekam profile image
Kamau Wanyee
Force multiplier in product/engineering teams. Currently helping Patrium Health re-imagine home based healthcare.
  • Location
    Nairobi, Kenya
  • Education
    Bsc. Informatics and Computer Science
  • Pronouns
    he/him
  • Work
    Product @ Patrium Health
  • Joined

Hey,
Out of curiosity, why does each tenant have their ownmanifest.json file?
I am assuming this is the generated manifest file for vite,

CollapseExpand
 
marcelokazalukian profile image
marcelo-kazalukian
  • Joined

Hello,

Every one of our clients will have the same features but they can customise the UI to look different. From the end users perspective every app will be different and every app can be installed with its own setup like name, icon, etc. For this we need a manifest and icons for each app.

Cheers.

CollapseExpand
 
harryhuddle profile image
Harry Potts
  • Joined

Thanks Kamau, certainly helped me get the fix for this quickly, was scratching my head for a moment there.

CollapseExpand
 
steekam profile image
Kamau Wanyee
Force multiplier in product/engineering teams. Currently helping Patrium Health re-imagine home based healthcare.
  • Location
    Nairobi, Kenya
  • Education
    Bsc. Informatics and Computer Science
  • Pronouns
    he/him
  • Work
    Product @ Patrium Health
  • Joined

I spent hours scratching my head so others won't have to :)

CollapseExpand
 
marcelokazalukian profile image
marcelo-kazalukian
  • Joined

Hello@steekam

Thanks for this article, it helped me a lot.

Now when I use the tenant_asset() function to define a manifest file for each tenant:

I get a URL like this:

subdomain.domain.com:8000/tenancy/...

Where should I put the manifest.json

Under storage, I have storage/tenant1/app

Thanks so much.

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Force multiplier in product/engineering teams. Currently helping Patrium Health re-imagine home based healthcare.
  • Location
    Nairobi, Kenya
  • Education
    Bsc. Informatics and Computer Science
  • Pronouns
    he/him
  • Work
    Product @ Patrium Health
  • Joined

More fromKamau Wanyee

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp