3

我正在尝试创建一个 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 位

4

1 回答 1

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

乔拉尔夫

于 2014-07-25T14:01:55.650 回答