Sass rails seems to generate a different logical p

2019-08-29 09:52发布

Until now I didn't have any problem with my production assets, though Heroku throws an error on having:

config.assets.compile = true

I have then decided to precompile locally and change the above with:

config.assets.compile = false
config.serve_static_assets = true

It now works fine when I use a Rails helper to reveal the path of assets :

style="background-image: url('<%= image_path("splash.jpg") %>');"

The above works well in production and it picks the fingerprinted version of the asset.

Though I have trouble with SASS RAILS which actually can do the same without having to write some Ruby. For example the following asset is not fingerprinted in Production and the font is not picked :

@font-face {
   font-family: "Myfont";
   src: asset-url("Myfont.ttf") format("truetype");
  }

Generated CSS in production :

@font-face{
font-family:"Myfont";
src:url("/assets/Myfont.ttf") format("truetype")
}

As you can see no link to the fingerprinted asset. the SASS helper seems to do the job correctly : https://github.com/rails/sass-rails#asset-helpers

Though my sprockets manifest file in the public folder shows :

Myfont-03a09f05dd555ee8b78d16411003a2e35f4322c05807f63db0039d23f71225a2.ttf":
{"logical_path":"Myfont.ttf",
"mtime":"2018-04-13T22:40:09+02:00",
"size":7916,
"digest":"03a09f05dd555ee8b78d16411003a2e35f4322c05807f63db0039d23f71225a2",
"integrity":"sha256-A6CfBd1VXui3jRZBEAOi419DIsBYB/Y9sAOdI/cSJaI="}

The logical path in manifest is different from the path generated by SASS RAILS helper. Is there a way to fix this ?

0条回答
登录 后发表回答