gulp-ruby-sass无法导入文件

时间:2014-07-21 16:44:23

标签: ruby-on-rails ruby-on-rails-3 sass gulp gulp-sass

我正在尝试创建gulp-ruby-sass任务但是我看到以下错误:

[17:32:34] gulp-ruby-sass: error ./styles.scss (Line 1: File to import not found
or unreadable: header.scss.
Load path: C:/Users/nassi/AppData/Local/Temp/gulp-ruby-sass)

我的项目结构:

app
    assets
        css
            _header.scss
            _home.scss
            _navigation.scss
            _buttons.scss
            _dialogs.scss
            styles.scss

在styles.scss中,我有:

@import "header.scss";
@import "home.scss";
@import "navigation.scss";
@import "buttons.scss";
@import "dialogs.scss";

我的吞咽任务:

var paths = {
    sass: ['assets/css/styles.scss']
};

// SASS task
gulp.task('sass', function () {
    gulp.src(paths.sass)
      .pipe(sass())
      .pipe(concat('all.min.css'))
      .pipe(gulp.dest('assets/css/'));
});

我新创建的all.min.css显示:

/*
Syntax error: File to import not found or unreadable: header.scss.
              Load path: C:/Users/nassi/AppData/Local/Temp/gulp-ruby-sass
        on line 1 of ./styles.scss

1: @import "header.scss";
2: @import "home.scss";
3: @import "navigation.scss";
4: @import "buttons.scss";
5: @import "dialogs.scss";

Backtrace:
./styles.scss:1
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/import_node.rb:66:in `rescue in import'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/import_node.rb:45:in `import'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/import_node.rb:28:in `imported_file'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/import_node.rb:37:in `css_import?'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/visitors/perform.rb:283:in `visit_import'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/visitors/base.rb:36:in `visit'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/visitors/perform.rb:152:in `block in visit'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/stack.rb:79:in `block in with_base'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/stack.rb:121:in `with_frame'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/stack.rb:79:in `with_base'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/visitors/perform.rb:152:in `visit'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/visitors/base.rb:52:in `map'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/visitors/base.rb:52:in `visit_children'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/visitors/perform.rb:161:in `block in visit_children'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/visitors/perform.rb:173:in `with_environment'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/visitors/perform.rb:160:in `visit_children'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/visitors/base.rb:36:in `block in visit'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/visitors/perform.rb:180:in `visit_root'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/visitors/base.rb:36:in `visit'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/visitors/perform.rb:151:in `visit'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/visitors/perform.rb:8:in `visit'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/root_node.rb:36:in `css_tree'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/tree/root_node.rb:20:in `render'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/engine.rb:274:in `render'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/plugin/compiler.rb:378:in `update_stylesheet'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/plugin/compiler.rb:189:in `block in update_stylesheets'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/plugin/compiler.rb:186:in `each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/plugin/compiler.rb:186:in `update_stylesheets'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/plugin.rb:82:in `update_stylesheets'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/exec.rb:489:in `watch_or_update'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/exec.rb:346:in `process_result'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/exec.rb:43:in `parse'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/lib/sass/exec.rb:22:in `parse!'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.3.10/bin/sass:13:in `<top (required)>'
C:/Ruby193/bin/sass:23:in `load'
C:/Ruby193/bin/sass:23:in `<main>'
*/
body:before {
  white-space: pre;
  font-family: monospace;

我在Bootcamp上运行Windows 7 64位

1 个答案:

答案 0 :(得分:3)

您必须使用loadPath选项,如下所示:

// SASS task
gulp.task('sass', function () {
    gulp.src(paths.sass)
        .pipe(sass({
            loadPath : __dirname + paths.sass
        }))
        .pipe(concat('all.min.css'))
        .pipe(gulp.dest('assets/css/'));
});

在较新版本的gulp-ruby-sass中有必要。

您可以导入的SASS-partials没有任何后缀:

@import "header";
@import "home";
@import "navigation";
@import "buttons";
@import "dialogs";

侨 拉尔夫