要导入的Sass文件未找到或不可读,文件确实存在

时间:2016-12-24 00:39:51

标签: css ruby sass

我正在编写一个ruby脚本来将SCSS编译到CSS中,它似乎找不到我要导入的文件。

这是我的ruby脚本,现在非常基本

require "sass"

template = File.read("brand_oit_appdev.scss")

puts template

options = {
  :syntax => :scss
}

render = Sass::Engine.new(template, options).render

puts render

这是brand_oit_appdev.scss

@import 'bootstrap_overrides';

header {
  .navbar-header {
    margin-left: 7px;

    a.umn-homepage {
      background-image: url(../images/revised-wordmark-transparent.png);
      background-repeat: no-repeat;
      margin-top: 4px;
      margin-left: -10px;
      height: 70px;
      width: 305px;
      display: block;

      span {
        visibility: hidden;
      }
    }
  }

  .global-links {
    margin-top:5px;
    font-weight: 200;
    font-size: .9em;

    ul {
      margin-bottom: 0;
    }

    a {
      color: $umn-white;
    }
  }

  .search-form {
    text-align: right;
    margin-top: 4px;
    margin-bottom: 0;
    margin-right: -15px;

    input {
      width: 15em !important;
      border-radius: 0 !important;
      border: none;
      transition: width .3s !important;

      &:focus {
        width: 21em !important;
      }
    }

    button {
      border: none;
      background-color: inherit;
      color: $umn-white;
      font-weight: bold;

      span {
        font-size: 1.8em;
      }

      &:hover, &:focus {
        color: $umn-white;
      }
    }
  }

  .navbar-brand {
    img {
      width: 32px;
      display: block;
      float: left;
      margin-right: 14px;
    }
  }

  .application-title {
    font-weight: 900;
  }
}

@media (-webkit-min-device-pixel-ratio: 2) {
  /* Retina-specific stuff here */
  .navbar-header {
    a.umn-homepage {
      background-image: url(../images/revised-wordmark-transparent@2x.png) !important;
      background-size: 410px 159px !important;
    }
  }
}

h1.page-header {
  font-weight: light;
}

.table-nonfluid {
  width: auto !important;
}

@media (max-width: $screen-sm-min) {
  .application-title {
    font-size: $font-size-h3 !important;
  }
}

html {
  position: relative;
  min-height: 100%;
}
body {
  margin-bottom: 6em;
}
table {
  .numeric {
    text-align: right;
  }
}
footer {
  font-size: .9em;
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 4.5em;
  text-align: center;
}

blockquote footer{
  position:relative;
  height:inherit;
  text-align:inherit;

}

.label-style{
  /* mimics Bootstrap's label styling */
  max-width:100%;
  margin-bottom:5px;
  font-weight:bold;
}


*:focus{

  border-color: rgba(82,168,236,.8)      !important;
  box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236,.6) !important;
  outline: 0 none !important;
   outline: thin dotted \9; /* IE6-9 */
}

这是错误

(sass):1: File to import not found or unreadable: bootstrap_overrides. (Sass::SyntaxError)
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/import_node.rb:67:in `rescue in import'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/import_node.rb:45:in `import'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/import_node.rb:28:in `imported_file'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/import_node.rb:37:in `css_import?'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/visitors/perform.rb:313:in `visit_import'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/visitors/base.rb:36:in `visit'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/visitors/perform.rb:160:in `block in visit'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/stack.rb:79:in `block in with_base'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/stack.rb:115:in `with_frame'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/stack.rb:79:in `with_base'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/visitors/perform.rb:160:in `visit'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/visitors/base.rb:52:in `map'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/visitors/base.rb:52:in `visit_children'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/visitors/perform.rb:169:in `block in visit_children'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/visitors/perform.rb:181:in `with_environment'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/visitors/perform.rb:168:in `visit_children'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/visitors/base.rb:36:in `block in visit'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/visitors/perform.rb:188:in `visit_root'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/visitors/base.rb:36:in `visit'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/visitors/perform.rb:159:in `visit'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/visitors/perform.rb:8:in `visit'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/root_node.rb:36:in `css_tree'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/tree/root_node.rb:20:in `render'
        from /home/jphamlett/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sass-3.4.23/lib/sass/engine.rb:281:in `render'
        from print-script.rb:11:in `<main>'

以下是src文件夹的截图

我不知道如何解决这个问题。我已经验证该文件是可读的,因为我能够从ruby命令中读取它。

任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

您需要使用load_paths更新Sass :: Engine选项。例如:

ImageView