SCSS 如何定位局部? [英] How does SCSS locate partials?

查看:38
本文介绍了SCSS 如何定位局部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在浏览 凉亭基础项目,但我对项目能够找到部分.特别是,我正在查看 _settings.scss 里面有一个相对引用我只是不太明白.

I'm looking through the bower foundation project and I'm getting stumped on how the project is able to locate the partials. In particular, I'm looking at the _settings.scss that has a relative reference in it I just don't quite understand.

在第 58 行有一个对 foundation/functions 的引用,但是这个部分 (_functions.scss) 是设置部分的兄弟.我很困惑为什么在该行中有对父目录 foundation 的引用.我也很困惑这是如何工作的.为什么设置文件不会在同级查找名为foundation的目录?

On line 58 there is a reference to foundation/functions but this partial (_functions.scss) is a sibling of the settings partial. I'm confused as why there is a reference to the parent directory foundation on that line. I'm also confused as to how this works. Why would the settings file not look for a directory named foundation at the same level?

推荐答案

如果您尝试导入不存在的文件,答案就很清楚了.以下是当您尝试 import "foo" 时在 http://sassmeister.com/ 上生成的错误的摘录";(不存在):

The answer becomes clear if you attempt to import a file that does not exist. Here's an excerpt of the error generated on http://sassmeister.com/ when you try to import "foo"; (which doesn't exist):

File to import not found or unreadable: foo.
Load paths:
  /app
  /app/lib/sass_modules
  /app/vendor/bundle/ruby/2.0.0/gems/compass-0.12.6/frameworks/blueprint/stylesheets
  /app/vendor/bundle/ruby/2.0.0/gems/compass-0.12.6/frameworks/compass/stylesheets
  /app/vendor/bundle/ruby/2.0.0/gems/susy-1.0.9/sass

如果 Sass 开始搜索与这些目录中的每一个相关的请求文件,直到找到它.

If Sass begins searching for the requested file relative to each of those directories until it finds it.

对于 vanilla Sass,可以通过 --import-path 选项添加额外的路径:

For vanilla Sass, one would add extra paths via the --import-path option:

sass --watch test.scss:test.css --load-path ../path/to/lib/ --load-path ../path/to/otherlib/

Compass 用户会在他们的 config.rb 中使用 additional_import_pathsadd_import_path(请参阅:http://compass-style.org/help/documentation/configuration-reference/)

Compass users would use additional_import_paths or add_import_path in their config.rb (see: http://compass-style.org/help/documentation/configuration-reference/)

add_import_path "../path/to/lib/"

只有 Foundation 的作者才能回答您关于为什么他们会以这种方式编写导入的具体问题.但这就是它起作用的原因.

Only the authors of Foundation can answer your specific question as to why they would write the import that way. But this is why it works.

这篇关于SCSS 如何定位局部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆