为什么Compass在尝试导入部分时会给我一个导入错误 [英] Why is Compass is giving me an import error when trying to import partials
问题描述
我的指南针项目目录结构如下所示
My compass project directory structure looks like this
s3z@s3z:~/Desktop/compass_project$ tree
.
├── basic.html
├── config.rb
├── css
│ ├── ie.css
│ ├── print.css
│ └── screen.css
├── index.html
├── partials
│ └── _normalize.scss
└── sass
├── ie.scss
├── print.scss
└── screen.scss
我的screen.scss文件如下所示
My screen.scss file looks like this
@import "compass";
@import "partials/normalize";
当我添加 @importpartials / normalize;
并保存,指南针向我吐出以下错误
When I add @import "partials/normalize";
and save it, Compass spits the following error back at me
>>> Compass is watching for changes. Press Ctrl-C to Stop.
>>> Change detected at 22:58:53 to: screen.scss
error sass/screen.scss (Line 2: File to import not found or unreadable: partials/normalize.
Load paths:
/home/max/Desktop/nettut_compass_tut/sass
/home/max/.rvm/gems/ruby-1.9.3-p194/gems/compass-0.12.2/frameworks/blueprint/stylesheets
/home/max/.rvm/gems/ruby-1.9.3-p194/gems/compass-0.12.2/frameworks/compass/stylesheets
Compass::SpriteImporter)
overwrite ./css/screen.css
以防万一我的 config.rb
是
http_path = "/"
css_dir = "css"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascripts"
有关如何解决此问题的任何想法?
推荐答案
您已经定义了 sass_dir
as sass
所以指南针正在寻找重置文件: sass / partials / normalize
如果你想要导入 sass_dir
之外的东西,你需要使用相对于正在进行导入的sass文件的路径:
You've defined your sass_dir
as sass
so compass is looking for that reset file in: sass/partials/normalize
If you want to import something outside of your sass_dir
, you need to use a path relative to the sass file that's doing the importing:
@import "../partials/normalize";
就个人而言,我更喜欢将部分目录放在sass目录中,或者只是让它们排序到顶部宽松。
personally, I prefer to put the partial directory in the sass directory, or just let them sort to the top loose.
这篇关于为什么Compass在尝试导入部分时会给我一个导入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!