rstacruz / sinatra-assetpack

Package your assets transparently in Sinatra.
http://ricostacruz.com/sinatra-assetpack/
MIT License
542 stars 97 forks source link

image not found when deployed to suburi #136

Closed mattaddy closed 10 years ago

mattaddy commented 10 years ago

I have the following in my application class.

register Sinatra::AssetPack

assets do
  serve "js",     from: File.join('assets', 'javascripts')
  serve "css",    from: File.join('assets', 'stylesheets')
  serve "images", from: File.join('assets', 'images')

  js  :app, ["js/jquery.js", "js/jquery.*.js", "js/app.js"]
  css :app, ["css/app.css"]
end

I'm using the js, css, and img helpers.

!= css :app
!= js  :app

!= img "images/fire.jpg", class: 'img'

In development, CSS, JavaScript, and images are all referenced as relative URL's (which works fine).

screen shot 2013-08-27 at 8 39 35 am screen shot 2013-08-27 at 8 40 05 am screen shot 2013-08-27 at 8 42 01 am

In production, however, images are not referenced correctly when I deploy to a suburi. The css and js helpers are referenced as absolute paths correctly ie,

/suburi/assets/app.<cache-buster>.css /suburi/assets/app.<cache-buster>.js

but the images are referenced relatively without the suburi

images/fire.jpg

If I manually navigate to the image referenced in production after prepending suburi to the image, it works.

I could of course reference the images by prepending suburi to the img calls. However, this would break in development.