Use Rails with faucet-pipeline
Instead of using the built-in asset pipeline of Rails, use
gem enables the required integration with Rails.
Why is an integration like that required?
faucet-pipeline modifies the names
of the generated files depending on their content (by adding a hash of the file
to the name), Rails will not be able to find the files on its own. You still
want to be able to use the helpers you are used to like
image_tag, and they should put out the correct URL for the desired asset.
This technique is referred to as cache busting.
application.js (for example in
faucet-pipeline generates a file called
application-03118e77692b637cfc0f55bb27fef087.js (for example in
stylesheet_link_tag 'application.css', you expect that the resulting HTML points to the file
containing the hash in its filename. To do that,
faucet-pipeline generates a
manifest file. In the case of using it with this Gem, it needs to save it as
public/assets/manifest.json (to change this, see the Configuration section)
And that's it. This gem will take care of the rest. The resulting HTML will look like this:
The types supported by this gem are:
Add this line to your application's Gemfile:
And then execute:
After this, you can ditch sprockets (aka the classic Rails asset pipeline)
for good. If you're on an existing Rails app, change the top of your
require 'rails/all' to:
# Pick the frameworks you want: require "active_record/railtie" require "active_storage/engine" require "action_controller/railtie" require "action_view/railtie" require "action_mailer/railtie" require "active_job/railtie" require "action_cable/engine" require "rails/test_unit/railtie" # require "sprockets/railtie" # Disable sprockets in favor of faucet require "active_model/railtie"
Make sure you customize this to your actual needs. The main takeaway here is
to not require
For fresh apps, you can just skip sprockets with:
rails new --skip-sprockets
You also need to install
Here are the instructions
This is a nice starting point for a
In this case, your
application.html.erb would contain lines like these:
By default this gem assumes that your manifest files can be found in
public/assets/manifest.json. You can change the path to the manifest
file with the following configuration:
config.faucet_pipeline.manifest_path = Rails.root.join("manifest.json")
manifest_path is an absolute path.
This gem also provides a Rake task
assets:precompile that runs faucet with the
--compact --fingerprint options. It can therefore be used as a drop-in replacement
for the task provided by the Rails asset pipeline. It only works if you install
your NPM dependencies to the default location (your app's
After checking out the repo, run
bin/setup to install dependencies. You can
bin/console for an interactive prompt that will allow you to
To install this gem onto your local machine, run
bundle exec rake install. To
release a new version, update the version number in
version.rb, and then run
bundle exec rake release, which will create a git tag for the version, push
git commits and tags, and push the
.gem file to
Bug reports and pull requests are welcome on GitHub at https://github.com/faucet-pipeline/faucet_pipeline_rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.