【问题标题】:Rails 4 fingerprinting causing 404 for bootstrap assets in production environmentRails 4 指纹识别导致生产环境中的引导资产出现 404
【发布时间】:2014-07-07 14:55:39
【问题描述】:

我在我的 Rails 4 应用程序中使用 bootstrap-sass gem,并且我使用了 Glpyphicons 字体,该字体包含引导程序用于我的应用程序中的图标。在开发中,这些图标显示得很好。但是,在任何非开发环境中,每次引用 Glyphicon 字体文件时都会出现 404 错误。

我确定这是由于资产管道完成的指纹识别破坏了 Bootstrap 样式表中的引用。

Bootstrap 引用这些字体:

@font-face {
  font-family: 'Glyphicons Halflings';
  src: url("bootstrap/glyphicons-halflings-regular.eot");
  src: url("bootstrap/glyphicons-halflings-regular.eot?#iefix") format("embedded-opentype"), url("bootstrap/glyphicons-halflings-regular.woff") format("woff"), url("bootstrap/glyphicons-halflings-regular.ttf") format("truetype"), url("bootstrap/glyphicons-halflings-regular.svg#glyphicons_halflingsregular") format("svg");
}

但是,引导文件夹的快速ls 显示名称不同。

glyphicons-halflings-regular-293ade90ddeb5ceccd08b9b32ae97010.eot
glyphicons-halflings-regular-533d84fb5d3948367e1b51dde3a08b39.svg
glyphicons-halflings-regular-d381f367f3f48c9f7f775a043238f0f8.ttf
glyphicons-halflings-regular-e5b007f195d752fa4823febe5e66ef4e.woff

如您所见,每个文件都附加了一个指纹。

删除这些指纹可解决此问题。但是,手动执行此操作并不适合部署。有没有人对此有任何解决方案?如果有帮助,我想避免编辑 bootstrap-sass gem 代码。

谢谢!

【问题讨论】:

    标签: ruby-on-rails-4 asset-pipeline bootstrap-sass asset-finger-printing precompile-assets


    【解决方案1】:

    在您的 application.css.scss 文件(或您为模板包含的任何 .css 文件)中

    你需要有

    @import "bootstrap-sprockets";
    @import "bootstrap";
    

    我认为您错过了导入 bootstrap-sprockets 文件。

    【讨论】:

    • 谢谢阿布舍克。今晚我会试一试!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多