2015-02-23 81 views
2

我想遍歷所有的涼亭軟件包。所有以sass文件作爲主要文件的文件,我都想要包含在includePaths中。gulp-sass不會導入使用涼亭安裝的bootstrap

我使用的NPM包main-bower-files成功讓我的主要文件(和我過濾只是scss文件)。

但是,當我去編譯,我得到以下錯誤(因爲現在引導是唯一一個我):

stream.js:94 
     throw er; // Unhandled stream error in pipe. 
      ^
Error: file to import not found or unreadable: bootstrap 

我gulpfile的相關部分是

var load_paths = bower({ 
    base: path.join(__dirname, "bower_components"), 
    filter: '**/_*.scss' 
}); 

gulp.src(app_css_file) 
.pipe(sass({ 
    includePaths: load_paths 
})) 
.pipe(concat('app.css')) 
.pipe(gulp.dest('build/css')); 

回答

1

我的問題原來是main-bower-files給你文件,而不是目錄。咄。 Node-sass需要包含可導入文件的目錄。

所以我必須稍微修改我的load_paths

for (var i=0; i<load_paths.length; i++){ 
    // we need to use the parent directories of the main files, not the files themselves 
    // so ./bower_components/bootstrap-sass-official/assets/stylesheets/_bootstrap.scss 
    // becomes ./bower_components/bootstrap-sass-official/assets/stylesheets 
    load_paths[i] = path.dirname(load_paths[i]); 
} 

而且固定它。希望這可以幫助別人:)