rails / sass-rails

Ruby on Rails stylesheet engine for Sass
MIT License
860 stars 333 forks source link

*-path helpers include host when config.asset.host set #355

Closed bschaeffer closed 8 years ago

bschaeffer commented 8 years ago

When config.asset.host is set, it is included in the output *-path helpers. I'm not sure if this is expected behavior, but it seems like it shouldn't be because we have both *-path and *-url helpers. Anyway, take the following.

application.css.scss

div {
  background: url(image-path('awesome/image.png'));
}

development.rb:

config.asset.host = nil

...and then rake assets:precompile produces:

div {
  background: url('/assets/awesome/image.png');
}

production.rb

config.asset.host = "https://mycdn.com/"

...and then RAILS_ENV=production rake assets:precompile produces:

div {
  background: url('https://mycdn.com/assets/awesome/image-{fingerprint}.png');
}

Is this the desired output? Not sure how to get the compiler to respect the fact that I want the path only.

rafaelfranca commented 8 years ago

It is the expected behavior. The -path method build only the URL, in the case 'https://mycdn.com/assets/awesome/image-{fingerprint}.png'. The -url method build the url() call and the URL of the asset so in this case url('https://mycdn.com/assets/awesome/image-{fingerprint}.png'). It is documented here.