How does SCSS locate partials?

旧城冷巷雨未停 提交于 2019-11-29 16:00:21

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

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

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 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/"

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.

Look at line 2 of your config.rb

add_import_path "bower_components/foundation/scss"

If you look at the sass in the file, the bower_components/foundation/_foundation.scss is just full of blanket imports for the rest of the components in foundation/components

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!