【发布时间】:2016-05-07 18:02:15
【问题描述】:
我正在用 ruby 编写自己的静态站点生成器,并且正在将 Sass 编译器添加到我的代码中。
def compile_sass
# system 'sass _sass/styles.scss styles.css'
options = {
syntax: :scss,
style: :compressed
}
render = Sass::Engine.new(File.read('_sass/styles.scss'), options).render
File.write('style.css', render)
end
但是当 styles.scss 文件中包含 @import 时会出现问题。导致
(sass):1: File to import not found or unreadable: variables. (Sass::SyntaxError)
两个 SCSS 文件都位于 _sass 文件夹中,主脚本位于根目录中,compile_sass 位于 _generator 中。但是当我取消注释系统调用并注释其余部分时,一切都按预期工作。
styles.scss
@import 'variables';
html {
background-color: red;
}
_variables.scss
body {
background-color: blue;
}
我几乎尝试了所有方法,检查了how to import stuff、looked at the documentation,但我找不到任何可以帮助我找到和定义问题的方法。
【问题讨论】:
-
为什么你希望
@import在导入的文件名前加上下划线? -
@mudasobwa 你不需要下划线来导入样式表..
-
@mudasobwa 他们的文档says I should put it in there(但不管有没有下划线都不起作用)。
-
可能工作目录在运行时改变了,尝试给
@import一个绝对路径 -
@maxpleaner 我尝试了所有可能的变体,有或没有.scss,有或没有下划线,但没有成功