Using Bower with Ruby Gem
The approach I take within Trestle is a little bit unorthodox. Some of the common ways to include asset-related dependencies in Rails is to either:
a) use a pre-packaged asset gem
b) use https://rails-assets.org/, or
c) include the assets beneath the vendor.
While option a) would be possible, it means that if the developer wants to use the same asset in their app, they must use the exact same version. Since Trestle uses some common dependencies such as jQuery and Bootstrap 3, I wanted to avoid this.
Option b) is also out since (as far as I know) it can’t be used for gem dependencies, only directly within an application's Gemfile.
Which leaves us with option c). Now rather than just download the assets directly into vendor/assets, we mange them using Bower so that they can be easily updated in future [side-note: I also use libraries.io to watch dependencies and notify me when they are updated]. By defining the dependencies in bower.json (and specifying a custom location for the bower_components directory in .bowerrc), we can then run
bower update to keep everything up to date.
Another side-note: Bower is technically a bit out of date and people will say to use npm or yarn. However I had difficulties with both of these. From memory, the problems were related to
1) customizing the install location, and
2) locking the dependency versions.
The glue files then get
into Trestle’s main admin.scss/admin.js files.