Open LeEnno opened 8 years ago
Could you check with sprockets-rails master and sprockets 3?
Trying with sprockets-rails master (and sprockets 3.4.0) gives following behavior:
<%= stylesheet_link_tag 'foo' %>
will tell me to place Rails.application.config.assets.precompile += %w( foo.css )
in my initializer. Unfortunately I already did this, but sprockets doesn't seem to recognize.
Additional info:
<%= stylesheet_link_tag 'foo/index' %>
works fine, although foo/index.css
is not in precompile array (foo.css
still is)foo/index-#{digest}.css
instead of foo-#{digest}.css
So it seems like adding foo.css
to the precompile array translates to foo/index.css
somewhere in the process, which I think is even weirder. Before (v2.3.3) it was just that foo.css
wasn't an option, you were forced to use foo/index.css
everywhere (in view helper and precompile array). Now (v3.0.0.beta3) both foo.css
or foo/index.css
can be used in precompile array, but only foo/index.css
is allowed in helpers.
This still seems like a regression to me, since it worked flawlessly with rails 3.2. So my question remains: is this desired behavior or a bug?
Thanks for your time and effort!
I'm experiencing a similar problem when I upgraded sprockets-rails to v2.2.4, during an Rails upgrade from 4.2.0 to 4.2.5.1.
My fix was also similar: I have to precompile the index file foo/index.js
and bar/index.js
instead, i.e.:
Rails.application.config.assets.precompile += ['foo/index.js', 'bar/index.js']
Not sure if this is intended, but definitely think this should be documented if it is.
But this enforcement of having to write foo/index
instead of foo
leaves the whole convention of index files useless, unless you use it in a require statement (*= require foo
). This difference between require
in asset files and stylesheet_link_tag
is confusing and probably not intended (I'd guess).
I'm using sprockets with its ability to use index files to organize assets. So with the following file structure under
app/assets/stylesheets/foo/
:app/assets/stylesheets/foo/index.css.scss
looks like this:My
config/initializers/asset.rb
says:So now on to the actual issue: in Rails 3.2.x this used to compile to
In Rails 4.2.x with sprockets-rails 2.3.3 it compiles to
This means that all my references a la
<%= stylesheet_link_tag 'foo' %>
are throwing errors likeWas this change intentional? If so, why is there a possibility to use sprockets with index files at all, if you can't actually reference them via helpers like
stylesheet_link_tag
etc?Additionally this leads to
localhost:3000/assets/foo.css
working in development, but not in production.So: is this a bug or desired behavior?
Regards, Enno