Reputation: 9304
We have a Rails 5 application and recently updated Sprockets from the 3.x series to 4.0.2. Now Rails can't find an asset (CSS file) belonging to a vendored gem. Note that the gem is an engine and the asset is called from a template inside the engine.
The asset is referenced inside a file at vendor/gems/our_vendored_gem/app/views/layouts/
like this:
<%= stylesheet_link_tag "our_vendored_gem/application", :media => "all" %>
The file is at vendor/gems/our_vendored_gem/app/assets/stylesheets/our_vendored_gem/application.css
Then we get the error Sprockets::Rails::Helper::AssetNotPrecompiled in OurVendoredGem::Mocks#index
.
Our app/assets/config/manifest.js
looks like this:
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
I tried adding
//= link_tree ../../../vendor/gems/our_vendored_gem/app/assets/stylesheets/ .css
...but that did not help. The vendored gem has a manifest file of its own but it is unclear to me if Sprockets is already reading it, or if it needs to be called somewhere.
What needs to happen to make this file available to Rails again?
Upvotes: 4
Views: 1589
Reputation: 9304
After some digging, I found this issue comment which explains that a Rails engine should have its own manifest file; that file can then be included in the application manifest like this:
//= link my_engine
This will find a manifest file at my_engine/app/assets/config/my_engine.js
and add those directives to those in the application manifest.
Upvotes: 4