Support for vendored assets

Hi there. I’ve run into quite a roadblock with vendored assets, and I’d like to propose more facilities for handling them than is present in this PR. That PR directly addresses vendor assets in a single app, but what about assets that need to be shared across multiple apps?

> tree -L 1 apps/
apps/
├── admin
├── auth
└── web

3 directories, 0 files

In this situation, I want to be able to use the Argon Bootstrap theme in each of those apps. I know that I can build a gem like @davydovanton’s hanami-bootstrap but I believe I should also be able to “plop” these files somewhere in my repo and include them while using the stylesheet and javascript helpers (I still want to take advantage of fingerprinting, CDN mode and integrity checking.)

Short of just putting these on a my own CDN, I’m curious what the community thinks about:

  • not deleting existing files inside public/ during asset precompilation
  • adding a lib/assets/ folder that stylesheet and javascript would respect
  • changing stylesheet and javascript such that if the path starts with a / then it translates to the root of public/. This would escape the app trap I’ve been running into.

Thoughts? I’m not necessarily proposing all of those points, just enumerating what’s in my head.

In one of the issues on Github, I saw that @jodosha will modify paths in vendor assets, but IMO, as soon as you do that, it’s no longer a truly “vendored” asset, as I’ve taken on the burden to maintain those modifications when upgrading to new versions.

Thanks for your input!

@jc00ke Hi. :wave: Given https://github.com/hanami/assets/pull/88 was merged and it will be included in hanami v1.3.0.beta1 (out in a few days). At that point the assets will preserve the vendored structure.

Did you try to add a vendor/assets/argon directory and then add it as a source for the assets:

Hanami::Assets.sources << "vendor/assets/argon"

This is the relevant documentation:


Would this solve your problem?

:wave: @jodosha, thanks for the quick reply!

That still looks like it’s “per application”, unless I’m not understanding the table in the PR description?

I just migrated to v1.3.0.beta via develop branch so I’ll play around with it.

So I got it working via the individual css file, and it preserves the directory structure :tada:

However, it still doesn’t allow me to truly vendor a package, as I would have to still address the paths to the fonts:

Those fonts were not copied over to public/assets/argon/assets/vendor/nucleo/fonts/ like I would need them to be.

What’s the source path?

I believe it was apps/web/assets/argon/... but I’ve since moved on to putting it all on my own CDN :frowning_man:

I still think it’s worth having a special vendor directory for assets though. I’d suggest it punts on fingerprinting and instead we document the asset’s directory should contain a version number.

Can you please explain in detail your proposals? I’m afraid I didn’t get them. Thanks. :slight_smile:

I propose we add a shared vendor directory that is available across all apps that does not fingerprint the assets. Vendored assets should be versioned already.

Right now, I have 4 apps, and they all use the same UI theme

apps/
├── admin
├── auth
├── participant
└── web

4 directories, 0 files

Right now, I don’t have a place to put the vendored files except onto a CDN. It’d be much nicer to have a lib/vendor/assets that only get served and don’t get copied to public/.

My short-term fix was to move all of these assets to a CDN on CloudFront. Now I just have javascript and stylesheet links in my different layout files.