我使用一些自定義的字體在我的Rails 4.1的應用程序。它們都坐落在這裏:Rails的資產管道:爲什麼我的自定義字體在發展,但不是生產工作?
app/assets/fonts/MyCustomFont.ttf
我引用他們在我的樣式表(SASS):
@font-face
font-family: "MyCustomFont"
src: url("MyCustomFont.ttf") format('truetype')
h1
color: #fff
font-family: "MyCustomFont"
在發展模式,它正確地呈現我的字體。當我部署到生產環境,我看到在日誌中提到的字體:
** Execute assets:precompile
I, [2014-09-12T23:46:40.077333 #12473] INFO -- : Writing /var/www/apps/10121/releases/c655762f076df708896b622c12429c8bf76f21ec/public/assets/MyCustomFont-18108066511bb5b3ddfd0454b738e8d5.ttf
然而,當我加載頁面在瀏覽器中它不會呈現自定義字體。 Web檢查控制檯顯示錯誤:
Failed to load resource: the server responded with a status of 404 (Not Found) http://example.com/assets/MyCustomFont.ttf
當我在使用日誌中列出的文件名的字體輸入URL:
http://example.com/assets/MyCustomFont-18108066511bb5b3ddfd0454b738e8d5.ttf
然後,瀏覽器觸發文件下載。因此,它似乎只是在錯誤的位置引用文件的問題。
我怎樣才能解決這個問題,什麼是引用的字體,使其在生產工作時的資產編制的正確方法是什麼?
沒有你嘗試運行'耙資產:precompile' – 2014-09-13 04:12:19
正如我所說的,當我部署到生產環境(並給日誌輸出的樣品)的資產被編譯。您不想在開發模式下運行該命令。 – Andrew 2014-09-13 18:43:35