Questions tagged [rails-sprockets]
43 questions
378
votes
14 answers
How can I disable logging of asset pipeline (sprockets) messages in Ruby on Rails 3.1?
Sprockets tends to be quite verbose in the (dev) log by default under Ruby on Rails 3.1 (RC1):
Started GET "/assets/application.css" for 127.0.0.1 at 2011-06-10 17:30:45 -0400
Compiled app/assets/stylesheets/application.css.scss (5ms) (pid…

istvanp
- 4,423
- 3
- 24
- 26
37
votes
2 answers
Rails 6: How to disable Webpack and use Sprockets instead
I'm migrating a Rails 5.2 app to 6.0 for ActionMailbox, ActionText, and multiple databases. However, I don't know webpack and would like to use Sprockets instead.
How do I properly remove webpack from Rails 6 and install Sprockets? rails new app…

Jun Dalisay
- 1,165
- 2
- 12
- 26
15
votes
1 answer
Asset application.css is not declared but it is declared in manifest
I got this error:
ActionView::Template::Error (Asset `application.css` was not declared to be precompiled in production.
Declare links to your assets in `app/assets/config/manifest.js`.
//= link application.css
and restart your server):
Rails…

Mehmet Kemal Bayer
- 323
- 4
- 13
11
votes
2 answers
How to use custom fonts in Rails 6 with Webpack
For my newly started Rails 6 application I want to have a set of customs fonts. My setup looks like this:
# app/assets/stylesheets/my-font.sass
@font-face
font-family: 'my-font'
src: url('fonts/my-font.eot') format('embedded-opentype'),…

Severin
- 8,508
- 14
- 68
- 117
10
votes
3 answers
Sprockets error Sprockets::NotImplementedError: Custom asset_path helper is not implemented
I am getting the following when trying to precompile my assets locally
RAILS_ENV=production bundle exec rake assets:precompile
rake aborted!
Sprockets::NotImplementedError: Custom asset_path helper is not implemented
Extend your environment…

cman77
- 1,753
- 1
- 22
- 48
8
votes
2 answers
Sprockets::Rails::Helper::AssetNotFound - The asset "my_logo.jpeg" is not present in the asset pipeline
Receiving this error, what am I missing?
Sprockets::Rails::Helper::AssetNotFound in Static#index:
The asset "my_logo.jpg" is not present in the asset pipeline.
ActionView::Template::Error (The asset "my_logo.jpg" is not present in the asset…

nictrix
- 1,483
- 1
- 17
- 34
6
votes
6 answers
LoadError: cannot load such file -- sassc
running rake assets:precompile ends with the error.
Can't find why it still requires sassc, sassc only was in project when migrated to sprockets 4 using Guide to upgrading from Sprockets 3.x to 4.x:
gem 'sass-rails', '>= 5'
bundle update sass-rails…

Goaul
- 943
- 11
- 13
5
votes
0 answers
How to reference assets by URL in JS in rails 7 with importmap and Sprockets?
In an application, I need to instantiate audio files from a JS file (I am using AudioContext API) more or less like this:
playAudio(url) {
this.audioContext = new (window.AudioContext || window.webkitAudioContext)();
let data = await…

ybart
- 876
- 8
- 23
4
votes
2 answers
Is it possible/advisable to run Rails 6 without webpack(er)?
I am starting a new Rails 6 application. If I understood correctly, Webpack(er) (gem webpacker) has replaced Sprockets as the new standard for including/minifying JS (source).
Furthermore, Rails 6 now both requires Node.js and Yarn.
Am I correct in…

chrisma
- 262
- 2
- 11
4
votes
2 answers
How does finger print digest gets calculated in Rails 4.2
I am using Rails 4.2 and the document states that the fingerprint is an md5 digest calculated based on the content of the compiled file.
If we take a file lets say application-4c697a2e67b1a921abbdc1f753c465d8.js, 4c697a2e67b1a921abbdc1f753c465d8 is…

Kinaan Khan Sherwani
- 1,504
- 16
- 28
4
votes
2 answers
How are Sprockets directives read in manifest file when using Rails?
New to Rails so bear with me...I was looking at a manifest file (application.js) today while researching the asset pipeline and was curious how the directives such as //= require jquery are being read. Is this something Sprockets is doing in the…

Craig Ness
- 83
- 1
- 6
4
votes
1 answer
Rails sprockets 3.0 find_asset
I used to use rails-sprockets 2.x and was using the following in an email layout template to include the css
Rails.application.assets.find_asset('file').to_s.html_safe
However, this no longer works in rails-sprockets 3.x and it is suggested to use…

Cjmarkham
- 9,484
- 5
- 48
- 81
2
votes
1 answer
How to make sprockets (or rack, or nginx?) motivate browsers to cache fonts and correctly return 304?
In a Rails6 app with webpacker replaced by sprockets, I do not manage to let sprockets make my browser cache fonts. Edit: my browser does cache the font, but google complains and curl shows how the App responds (not as expected with a 304, see…

Felix
- 4,510
- 2
- 31
- 46
2
votes
1 answer
Creating a new stylesheet during a request and then immediately requiring it gives an error
It seems that Sprockets has a cached environment built in that loads a list of all possible assets at the start of a request, and then requiring any assets outside that list raises an error.
I've written a custom directive to create a new CSS file -…

sevenseacat
- 24,699
- 6
- 63
- 88
1
vote
1 answer
Upgrade Rails 6.1 > 7.0, add turbo-rails and importmap, gems do not install
I'm trying to upgrade a working legacy app to Rails 7, from Rails 6.1. I want to use Hotwire, so I added gem turbo-rails.
Ruby 3.1.2
zeitwerk
no webpacker
sprockets-rails
no modern JS yet
app passes tests
server boots locally
Added gem…

nimmolo
- 191
- 3
- 14