0

我正在尝试使用 html shim 来包含 IE 特定的样式表。但是,一旦部署到heroku,就会一直遇到“ActionView::Template::Error(ie/IE9.css 未预编译):”错误。它似乎在本地工作。

我一直在为资产尝试不同的组合和位置,但到目前为止没有任何效果。

我当前的配置如下。

IE 特定文件位于:

app/assets/stylesheets/ie/index.css.scss
app/assets/stylesheets/ie/IE9.css.scss
app/assets/stylesheets/ie/IE8.css.scss
app/assets/stylesheets/ie/IE7.css.scss
app/assets/stylesheets/ie/IE6.css.scss

index.css.scss

/*
*= require_tree .
*/

应用程序.html.haml

/[if gte IE 9]
  = stylesheet_link_tag "ie/IE9", media: "all"

应用程序.css.scss

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the top of the
 * compiled file, but it's generally better to create a new file per style scope.
 *
 *= require bootstrap
 *= require baseline
 *= require base10creations/gallery_required
 *= require ie
 *= require_self

*/

@import 'baseline.css.scss';
@import 'rem.css.scss';
@import 'common.css.scss';
@import 'admin.css.scss';
@import 'layout.css.scss';
@import 'pages.css.scss';
@import 'components.css.scss';
@import 'forms.css.scss';
@import 'override.css.scss';
4

2 回答 2

0

您的情况有几个选择:

  • 在您的application.css添加中:

    *= 要求树。

  • 使用索引文件技术,它只需要在您的ie/目录中创建一个具有相同内容的新“索引”文件(*= require_tree .);

我建议删除

config.assets.precompile += ["IE9.css", "IE8.css", "IE7.css", "IE6.css"]

从您production.rb 和您对游览布局文件中的 IE 垫片的有条件调用application.html.haml

编辑:为 IE 提供更好的 js:

  /[if lt IE 9]
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
于 2013-04-04T00:02:43.953 回答
0

我最终只使用了一个链接标签而不是 rails stylesheet_link_tag。虽然我不知道为什么 stylesheet_link_tag 不合适。

工作文件是:

目录结构

app/assets/stylesheets/ie/index.css.scss
app/assets/stylesheets/ie/IE9.css.scss
app/assets/stylesheets/ie/IE8.css.scss
app/assets/stylesheets/ie/IE7.css.scss
app/assets/stylesheets/ie/IE6.css.scss

index.css.scss

/*
*= require_tree .
*/

应用程序.html.haml

!!!
%html
  %head
    %meta{:charset => "UTF-8"}/
    %title= "Title"
    = stylesheet_link_tag "application", media: "all"
    = javascript_include_tag "application"
    = csrf_meta_tags
    /[if lt IE 9]
      %script{ src: "http://html5shim.googlecode.com/svn/trunk/html5.js", type: "text/javascript" }
    /[if gte IE 9]
      %link{ href: "ie/IE9.css" }
  %body
    #container
      = render :partial => "layouts/header"
      #content
        #messages
          - flash.each do |name, msg|
            = content_tag :div, msg, :id => "flash_#{name}"
        = yield
      = render :partial => "layouts/footer"

应用程序.css.scss

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the top of the
 * compiled file, but it's generally better to create a new file per style scope.
 *
 *= require bootstrap
 *= require baseline
 *= require base10creations/gallery_required
 *= require ie
 *= require_self

*/

@import 'baseline.css.scss';
@import 'rem.css.scss';
@import 'common.css.scss';
@import 'admin.css.scss';
@import 'layout.css.scss';
@import 'pages.css.scss';
@import 'components.css.scss';
@import 'forms.css.scss';
@import 'override.css.scss';
于 2013-04-04T02:29:47.350 回答