avo
avo copied to clipboard
Add fingerprinting to Avo's assets for easier CDN deployment
Feature
Some users deploy the assets to a CDN. For a CDN to work properly, the assets should have fingerprinted filenames.
This is something others did.
# config/assets/rb
avo = Bundler.load.specs.find { |s| [http://s.name](https://t.co/bcO4DYlGDI) == "avo" }
Rails.application.config.assets.paths << "#{avo.full_gem_path}/public"
Rails.application.config.after_initialize do
Rails.application.config.assets.precompile += ["avo-assets/avo.base.css", "avo-assets/avo.base.js"]
end
Maybe we could expose the asset-building infrastructure so folks can compile the assets independently.
To really bring this home, it would be great if Avo could also request the fingerprinted assets without requiring ejection of the application layout.
To make things work on our end, we built the assets under /assets/avo-assets/avo.base-12345.js, but then ejected application layout (bin/rails generate avo:eject app/views/layouts/avo/application.html.erb to remove leading slashes from the asset request paths like so:
<%= javascript_include_tag "avo-assets/avo.base", "data-turbo-track": "reload", defer: true %>
<%= stylesheet_link_tag "avo-assets/avo.base", "data-turbo-track": "reload", defer: true %>
This way, Rails requests assets at the paths as described above.
Perhaps this could be all driven by a configuration option.
Definitely using a configuration option!
Are you able to continue using Avo like that? I'd like to explore the fingerprinting feature after we launch Avo 3.
Yes, this is workable in the near-term. I think it's fine if you wanted to make it a v3 feature.
Those were my thoughts too. v3 to have it as a feature.
Closed by https://github.com/avo-hq/avo/pull/3971