Precompilation of specific assets without fingerprint md5

in my rails 4 project css uses font files. therefore, they must first be compiled.

I achieve this by adding the following lines to config / environment / production.rb

# Add the fonts path config.assets.paths << Rails.root.join('vendor', 'assets', 'fonts','fonts') # # # Precompile additional assets config.assets.precompile += %w( *.svg *.eot *.woff *.ttf ) 

and launches rake assets: precompilation in production.

however, the result is as follows:

 I, [2013-10-10T19:27:51.931963 #16052] INFO -- : Writing /var/lib/openshift/521e19c85004460a8e000107/app-root/runtime/repo/public/assets/fonts/glyphicons-halflings-regular-ab2f6984951c07fd89e6afdefabd93c7.eot I, [2013-10-10T19:27:51.940615 #16052] INFO -- : Writing /var/lib/openshift/521e19c85004460a8e000107/app-root/runtime/repo/public/assets/fonts/glyphicons-halflings-regular-24dfb40c91db789b8b8faba6886ac1ef.svg I, [2013-10-10T19:27:51.950685 #16052] INFO -- : Writing /var/lib/openshift/521e19c85004460a8e000107/app-root/runtime/repo/public/assets/fonts/glyphicons-halflings-regular-4b2130768da98222338d1519f9179528.ttf I, [2013-10-10T19:27:51.983230 #16052] INFO -- : Writing /var/lib/openshift/521e19c85004460a8e000107/app-root/runtime/repo/public/assets/fonts/glyphicons-halflings-regular-7a07f26f72466361ac9671de2d33fd1c.woff 

and css files refer to font files without this md5 fingerprint.

How can I pre-assemble assets so that they are generated without an md5 fingerprint? or should I just put them in the public / fonts / folder in that case?

+6
source share
1 answer

Follow these steps.

  • Your font should be in app/assets/fonts
  • Add the font to the resource path (like you), but prefer config/application.rb
  • Declare your font in CSS using @font-face . You will find some help here.
  • If you are not using SCSS, you must have built-in css, for example application.css.erb , and use the asset_path() helper to implement your font path in the font declaration.

Example without SCSS:

 @font-face { font-family: 'MyFont'; src:url('<%= asset_path("myfont.eot")%>'); src:url('<%= asset_path("myfont.eot?#iefix")%>') format('embedded-opentype'), url('<%= asset_path("myfont.svg#myfont")%>') format('svg'), url('<%= asset_path("myfont.woff")%>') format('woff'), url('<%= asset_path("myfont.ttf")%>') format('truetype'); font-weight: normal; font-style: normal; } 
+2
source

Source: https://habr.com/ru/post/955722/


All Articles