Description
This gem currently bundles the Inter font as part of its assets, which gets included in any project depending on it. As such it will also be picked up by rails assets:prepare
and output into the public assets directory, whether the project uses the font or not. I'd like to propose these assets be removed from tailwindcss-rails
or alternatively be included in a way that does not force assets into downstream projects.
I know Inter is often used in Tailwind examples and as a starting point for smaller projects. This makes sense. But this gem should in my mind also be the preferred way for larger Rails projects using Tailwind, where Inter is unlikely to be the font of choice. In these cases, including the font assets with no way of opting out creates unnecessary clutter in those projects & deployments.
Possible actions
- Remove the font assets. The Inter font project has an official CDN provided by Cloudfront that could be a documented suggestion for new projects & upgrade path. This would of course be a breaking change.
- If there's a way for Rails engines to conditionally provide assets, move to using that. I'm not aware of any such methods myself though(?).
Workaround
I'm currently hacking my way out of these assets with the following configuration. I'm open to suggestions on how to do this in a cleaner way if possible. A clean & documented way to do this might remove the need for the proposed change.
Rails.application.config.to_prepare do
Rails.application.config.assets.precompile -= %w[inter-font.css]
Rails.application.config.assets.paths.reject! { _1.is_a?(String) && _1.include?('gems/tailwindcss-rails') }
end
I'd like to hear what you (maintainers) think about this. If this is a desirable change, I'm open to working on a PR.