Access to a compiled asset with Sprockets 4

Viewed 114

I have an issue migrating from Sprockets 3 to Sprockets 4

In my amp page layout I have

- if Rails.application.assets && Rails.application.assets['amp/application']
      style(amp-custom)
        =Rails.application.assets['amp/application'].to_s.html_safe
    - else
      style(amp-custom)
        =File.read("#{Rails.root}/public#{stylesheet_path('amp/application', host: nil)}").gsub(/[\"]/,"'")

And of course I have an amp/application.scss file with my stylesheet.

With Sprockets 3.0

=Rails.application.assets['amp/application'].to_s.html_safe

Return to me a compiled version in css, with Sprockets 4 I have only the scss version.

Why?

1 Answers

Try this one

=Rails.application.assets['amp/application**.css**'].to_s.html_safe

I managed to get it works by telling the Sprocket to get the precompiled css file instead of the raw scss file

Related